Commit e80234f8 authored by Masahide Nakamura's avatar Masahide Nakamura Committed by Hideaki Yoshifuji

[IPV4] XFRM: probe icmp type/code when sending packets via raw socket.

Signed-off-by: default avatarMasahide Nakamura <nakam@linux-ipv6.org>
Signed-off-by: default avatarHideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
parent 838eed90
......@@ -323,6 +323,51 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length,
return err;
}
static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
{
struct iovec *iov;
u8 *type = NULL;
u8 *code = NULL;
int probed = 0;
int i;
if (!msg->msg_iov)
return;
for (i = 0; i < msg->msg_iovlen; i++) {
iov = &msg->msg_iov[i];
if (!iov)
continue;
switch (fl->proto) {
case IPPROTO_ICMP:
/* check if one-byte field is readable or not. */
if (iov->iov_base && iov->iov_len < 1)
break;
if (!type) {
type = iov->iov_base;
/* check if code field is readable or not. */
if (iov->iov_len > 1)
code = type + 1;
} else if (!code)
code = iov->iov_base;
if (type && code) {
fl->fl_icmp_type = *type;
fl->fl_icmp_code = *code;
probed = 1;
}
break;
default:
probed = 1;
break;
}
if (probed)
break;
}
}
static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
size_t len)
{
......@@ -429,6 +474,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.proto = inet->hdrincl ? IPPROTO_RAW :
sk->sk_protocol,
};
raw_probe_proto_opt(&fl, msg);
err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
}
if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment