diff options
author | ae <ae@FreeBSD.org> | 2017-05-24 09:03:46 +0000 |
---|---|---|
committer | ae <ae@FreeBSD.org> | 2017-05-24 09:03:46 +0000 |
commit | b974d27de014b3ea652caa4ea60bafbf3f65b14f (patch) | |
tree | eb8ef2b6949d0e53d5d080a74b3ad241134a76f2 | |
parent | c9bf380cdc6cd74a7fd4e3b9cb4333d056580ff5 (diff) | |
download | FreeBSD-src-b974d27de014b3ea652caa4ea60bafbf3f65b14f.zip FreeBSD-src-b974d27de014b3ea652caa4ea60bafbf3f65b14f.tar.gz |
MFC r318399:
Set M_BCAST and M_MCAST flags on mbuf sent via divert socket.
r290383 has changed how mbufs sent by divert socket are handled.
Previously they are always handled by slow path processing in ip_input().
Now ip_tryforward() is invoked from ip_input() before in_broadcast() check.
Since diverted packet lost all mbuf flags, it passes the broadcast check
in ip_tryforward() due to missing M_BCAST flag. In the result the broadcast
packet is forwarded to the wire instead of be consumed by network stack.
Add in_broadcast() check to the div_output() function. And restore the
M_BCAST flag if destination address is broadcast for the given network
interface.
PR: 209491
-rw-r--r-- | sys/netinet/ip_divert.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 4d4572f..fcb7c3e 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -489,6 +489,14 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin, /* Send packet to input processing via netisr */ switch (ip->ip_v) { case IPVERSION: + /* + * Restore M_BCAST flag when destination address is + * broadcast. It is expected by ip_tryforward(). + */ + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) + m->m_flags |= M_MCAST; + else if (in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) + m->m_flags |= M_BCAST; netisr_queue_src(NETISR_IP, (uintptr_t)so, m); break; #ifdef INET6 |