Commit 9c7e9d2d authored by Masahide Nakamura's avatar Masahide Nakamura Committed by Hideaki Yoshifuji

[IPV6] XFRM: probe icmpv6 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 682d3484
......@@ -555,6 +555,52 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
return err;
}
static void rawv6_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_ICMPV6:
/* 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 rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len)
{
......@@ -674,6 +720,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
opt = fl6_merge_options(&opt_space, flowlabel, opt);
fl.proto = proto;
rawv6_probe_proto_opt(&fl, msg);
ipv6_addr_copy(&fl.fl6_dst, daddr);
if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
......
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