diff options
author | David Ahern <dsahern@gmail.com> | 2018-02-16 11:03:03 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-02-16 16:42:17 -0500 |
commit | 1cbec07649ec8c267cdfb486ab4ee73949974ca4 (patch) | |
tree | 40486285e2433d9ceb26485f1351d19d099bd997 /net/ipv4/ip_sockglue.c | |
parent | b2d12101bff95c27960c69f3e54a98afdc205bb3 (diff) | |
download | linux-stable-1cbec07649ec8c267cdfb486ab4ee73949974ca4.tar.gz linux-stable-1cbec07649ec8c267cdfb486ab4ee73949974ca4.tar.bz2 linux-stable-1cbec07649ec8c267cdfb486ab4ee73949974ca4.zip |
net: Only honor ifindex in IP_PKTINFO if non-0
Only allow ifindex from IP_PKTINFO to override SO_BINDTODEVICE settings
if the index is actually set in the message.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_sockglue.c')
-rw-r--r-- | net/ipv4/ip_sockglue.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 008be04ac1cc..9dca0fb8c482 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -258,7 +258,8 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg); if (!ipv6_addr_v4mapped(&src_info->ipi6_addr)) return -EINVAL; - ipc->oif = src_info->ipi6_ifindex; + if (src_info->ipi6_ifindex) + ipc->oif = src_info->ipi6_ifindex; ipc->addr = src_info->ipi6_addr.s6_addr32[3]; continue; } @@ -288,7 +289,8 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct in_pktinfo))) return -EINVAL; info = (struct in_pktinfo *)CMSG_DATA(cmsg); - ipc->oif = info->ipi_ifindex; + if (info->ipi_ifindex) + ipc->oif = info->ipi_ifindex; ipc->addr = info->ipi_spec_dst.s_addr; break; } |