Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144670909
D48707.1776103334.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D48707.1776103334.diff
View Options
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
@@ -128,6 +127,12 @@
void (*ip_rsvp_force_done)(struct socket *);
#endif /* INET */
+#define V_rip_bind_all_fibs VNET(rip_bind_all_fibs)
+VNET_DEFINE(int, rip_bind_all_fibs) = 1;
+SYSCTL_INT(_net_inet_raw, OID_AUTO, bind_all_fibs, CTLFLAG_VNET | CTLFLAG_RDTUN,
+ &VNET_NAME(rip_bind_all_fibs), 0,
+ "Bound sockets receive traffic from all FIBs");
+
u_long rip_sendspace = 9216;
SYSCTL_ULONG(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW,
&rip_sendspace, 0, "Maximum outgoing raw IP datagram size");
@@ -302,7 +307,9 @@
struct mbuf *m = *mp;
struct inpcb *inp;
struct sockaddr_in ripsrc;
- int appended;
+ int appended, fib;
+
+ M_ASSERTPKTHDR(m);
*mp = NULL;
appended = 0;
@@ -312,6 +319,7 @@
ripsrc.sin_family = AF_INET;
ripsrc.sin_addr = ctx.ip->ip_src;
+ fib = M_GETFIB(m);
ifp = m->m_pkthdr.rcvif;
inpi.hash = INP_PCBHASH_RAW(proto, ctx.ip->ip_src.s_addr,
@@ -326,6 +334,12 @@
*/
continue;
}
+ if (V_rip_bind_all_fibs == 0 && fib != inp->inp_inc.inc_fibnum)
+ /*
+ * Sockets bound to a specific FIB can only receive
+ * packets from that FIB.
+ */
+ continue;
appended += rip_append(inp, ctx.ip, m, &ripsrc);
}
@@ -343,6 +357,9 @@
* and fall through into normal filter path if so.
*/
continue;
+ if (V_rip_bind_all_fibs == 0 && fib != inp->inp_inc.inc_fibnum)
+ continue;
+
/*
* If this raw socket has multicast state, and we
* have received a multicast, check if this socket
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -143,6 +143,9 @@
VNET_DECLARE(struct inpcbinfo, ripcbinfo);
#define V_ripcbinfo VNET(ripcbinfo)
+VNET_DECLARE(int, rip_bind_all_fibs);
+#define V_rip_bind_all_fibs VNET(rip_bind_all_fibs)
+
static void icmp6_errcount(int, int);
static int icmp6_rip6_input(struct mbuf **, int);
static void icmp6_reflect(struct mbuf *, size_t);
@@ -1934,7 +1937,7 @@
struct sockaddr_in6 fromsa;
struct icmp6_hdr *icmp6;
struct mbuf *opts = NULL;
- int delivered = 0;
+ int delivered = 0, fib;
/* This is assumed to be safe; icmp6_input() does a pullup. */
icmp6 = (struct icmp6_hdr *)((caddr_t)ip6 + off);
@@ -1953,7 +1956,15 @@
return (IPPROTO_DONE);
}
+ fib = M_GETFIB(m);
+
while ((inp = inp_next(&inpi)) != NULL) {
+ if (V_rip_bind_all_fibs == 0 && fib != inp->inp_inc.inc_fibnum)
+ /*
+ * Sockets bound to a specific FIB can only receive
+ * packets from that FIB.
+ */
+ continue;
if (ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
inp->in6p_icmp6filt))
continue;
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -59,7 +59,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "opt_ipsec.h"
#include "opt_inet6.h"
#include "opt_route.h"
@@ -118,6 +117,9 @@
VNET_DECLARE(struct inpcbinfo, ripcbinfo);
#define V_ripcbinfo VNET(ripcbinfo)
+VNET_DECLARE(int, rip_bind_all_fibs);
+#define V_rip_bind_all_fibs VNET(rip_bind_all_fibs)
+
extern u_long rip_sendspace;
extern u_long rip_recvspace;
@@ -190,14 +192,16 @@
struct rip6_inp_match_ctx ctx = { .ip6 = ip6, .proto = proto };
struct inpcb_iterator inpi = INP_ITERATOR(&V_ripcbinfo,
INPLOOKUP_RLOCKPCB, rip6_inp_match, &ctx);
- int delivered = 0;
+ int delivered = 0, fib;
+ M_ASSERTPKTHDR(m);
NET_EPOCH_ASSERT();
RIP6STAT_INC(rip6s_ipackets);
init_sin6(&fromsa, m, 0); /* general init */
+ fib = M_GETFIB(m);
ifp = m->m_pkthdr.rcvif;
while ((inp = inp_next(&inpi)) != NULL) {
@@ -221,6 +225,12 @@
* and fall through into normal filter path if so.
*/
continue;
+ if (V_rip_bind_all_fibs == 0 && fib != inp->inp_inc.inc_fibnum)
+ /*
+ * Sockets bound to a specific FIB can only receive
+ * packets from that FIB.
+ */
+ continue;
if (inp->in6p_cksum != -1) {
RIP6STAT_INC(rip6s_isum);
if (m->m_pkthdr.len - (*offp + inp->in6p_cksum) < 2 ||
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 13, 6:02 PM (3 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28339412
Default Alt Text
D48707.1776103334.diff (4 KB)
Attached To
Mode
D48707: rawip: Add a bind_all_fibs mode
Attached
Detach File
Event Timeline
Log In to Comment