diff options
author | Stef Walter <stef@memberwebs.com> | 2009-09-11 00:32:50 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2009-09-11 00:32:50 +0000 |
commit | 7d0270d7783647e33f69e9889c33db255ca6b081 (patch) | |
tree | 02bb85e505af9f8fa9d92b7b607dbc26f105077f | |
parent | 4727a8ca57904d87599c79d3662c584f4c560af4 (diff) |
Add setfib support to route messages
-rw-r--r-- | kernel-7.1/freebsd-route-messages-respect-fib-2.patch | 234 |
1 files changed, 234 insertions, 0 deletions
diff --git a/kernel-7.1/freebsd-route-messages-respect-fib-2.patch b/kernel-7.1/freebsd-route-messages-respect-fib-2.patch new file mode 100644 index 0000000..93a2ae7 --- /dev/null +++ b/kernel-7.1/freebsd-route-messages-respect-fib-2.patch @@ -0,0 +1,234 @@ +--- ./sys/net/rtsock.c.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/net/rtsock.c 2009-09-11 00:07:13.000000000 +0000 +@@ -83,4 +83,9 @@ + &rtsintrq.ifq_maxlen, 0, "maximum routing socket dispatch queue length"); + ++struct rt_dispatch_ctx { ++ unsigned short family; /* Socket family */ ++ int fibnum; /* FIB for message or -1 for all */ ++}; ++ + struct walkarg { + int w_tmemsize; +@@ -104,5 +109,5 @@ + static void rt_getmetrics(const struct rt_metrics_lite *in, + struct rt_metrics *out); +-static void rt_dispatch(struct mbuf *, const struct sockaddr *); ++static void rt_dispatch(struct mbuf *, const struct sockaddr *, int); + + static void +@@ -123,17 +128,19 @@ + { + struct sockproto route_proto; +- unsigned short *family; ++ struct rt_dispatch_ctx *ctx; + struct m_tag *tag; ++ int fibnum = -1; + + route_proto.sp_family = PF_ROUTE; +- tag = m_tag_find(m, PACKET_TAG_RTSOCKFAM, NULL); ++ tag = m_tag_find(m, PACKET_TAG_RTSOCK, NULL); + if (tag != NULL) { +- family = (unsigned short *)(tag + 1); +- route_proto.sp_protocol = *family; ++ ctx = (struct rt_dispatch_ctx*)(tag + 1); ++ route_proto.sp_protocol = ctx->family; ++ fibnum = ctx->fibnum; + m_tag_delete(m, tag); + } else + route_proto.sp_protocol = 0; + +- raw_input(m, &route_proto, &route_src); ++ raw_input(m, &route_proto, &route_src, fibnum); + } + +@@ -605,8 +612,8 @@ + unsigned short family = rp->rcb_proto.sp_family; + rp->rcb_proto.sp_family = 0; +- rt_dispatch(m, info.rti_info[RTAX_DST]); ++ rt_dispatch(m, info.rti_info[RTAX_DST], so->so_fibnum); + rp->rcb_proto.sp_family = family; + } else +- rt_dispatch(m, info.rti_info[RTAX_DST]); ++ rt_dispatch(m, info.rti_info[RTAX_DST], so->so_fibnum); + } + } +@@ -829,5 +836,5 @@ + */ + void +-rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error) ++rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error, int fibnum) + { + struct rt_msghdr *rtm; +@@ -844,5 +851,5 @@ + rtm->rtm_errno = error; + rtm->rtm_addrs = rtinfo->rti_addrs; +- rt_dispatch(m, sa); ++ rt_dispatch(m, sa, fibnum); + } + +@@ -869,5 +876,5 @@ + ifm->ifm_data = ifp->if_data; + ifm->ifm_addrs = 0; +- rt_dispatch(m, NULL); ++ rt_dispatch(m, NULL, -1); + } + +@@ -881,5 +888,5 @@ + */ + void +-rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) ++rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt, int fibnum) + { + struct rt_addrinfo info; +@@ -937,5 +944,5 @@ + rtm->rtm_addrs = info.rti_addrs; + } +- rt_dispatch(m, sa); ++ rt_dispatch(m, sa, fibnum); + } + } +@@ -973,5 +980,5 @@ + ifmam->ifmam_index = ifp->if_index; + ifmam->ifmam_addrs = info.rti_addrs; +- rt_dispatch(m, ifma->ifma_addr); ++ rt_dispatch(m, ifma->ifma_addr, -1); + } + +@@ -1033,5 +1040,5 @@ + m->m_pkthdr.len += data_len; + mtod(m, struct if_announcemsghdr *)->ifan_msglen += data_len; +- rt_dispatch(m, NULL); ++ rt_dispatch(m, NULL, -1); + } + } +@@ -1049,10 +1056,11 @@ + m = rt_makeifannouncemsg(ifp, RTM_IFANNOUNCE, what, &info); + if (m != NULL) +- rt_dispatch(m, NULL); ++ rt_dispatch(m, NULL, -1); + } + + static void +-rt_dispatch(struct mbuf *m, const struct sockaddr *sa) ++rt_dispatch(struct mbuf *m, const struct sockaddr *sa, int fibnum) + { ++ struct rt_dispatch_ctx *ctx; + struct m_tag *tag; + +@@ -1060,14 +1068,16 @@ + * Preserve the family from the sockaddr, if any, in an m_tag for + * use when injecting the mbuf into the routing socket buffer from +- * the netisr. ++ * the netisr. Additionally save the fibnum if needed. + */ +- if (sa != NULL) { +- tag = m_tag_get(PACKET_TAG_RTSOCKFAM, sizeof(unsigned short), +- M_NOWAIT); ++ if (sa != NULL || fibnum >= 0) { ++ tag = m_tag_get(PACKET_TAG_RTSOCK, ++ sizeof(struct rt_dispatch_ctx*), M_NOWAIT); + if (tag == NULL) { + m_freem(m); + return; + } +- *(unsigned short *)(tag + 1) = sa->sa_family; ++ ctx = (struct rt_dispatch_ctx*)(tag + 1); ++ ctx->family = sa->sa_family; ++ ctx->fibnum = fibnum; + m_tag_prepend(m, tag); + } +--- ./sys/net/raw_usrreq.c.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/net/raw_usrreq.c 2009-09-11 00:07:13.000000000 +0000 +@@ -68,5 +68,5 @@ + */ + void +-raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src) ++raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, int fibnum) + { + struct rawcb *rp; +@@ -82,4 +82,7 @@ + rp->rcb_proto.sp_protocol != proto->sp_protocol) + continue; ++ if (fibnum >= 0 && rp->rcb_socket && ++ fibnum != rp->rcb_socket->so_fibnum) ++ continue; + if (last) { + struct mbuf *n; +--- ./sys/net/raw_cb.h.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/net/raw_cb.h 2009-09-11 00:07:13.000000000 +0000 +@@ -71,5 +71,5 @@ + int raw_attach(struct socket *, int); + void raw_detach(struct rawcb *); +-void raw_input(struct mbuf *, struct sockproto *, struct sockaddr *); ++void raw_input(struct mbuf *, struct sockproto *, struct sockaddr *, int); + + /* +--- ./sys/net/route.c.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/net/route.c 2009-09-11 00:08:28.000000000 +0000 +@@ -338,5 +338,5 @@ + info.rti_info[RTAX_IFA] = newrt->rt_ifa->ifa_addr; + } +- rt_missmsg(RTM_ADD, &info, newrt->rt_flags, 0); ++ rt_missmsg(RTM_ADD, &info, newrt->rt_flags, 0, fibnum); + } else { + KASSERT(rt == newrt, ("locking wrong route")); +@@ -362,5 +362,5 @@ + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = dst; +- rt_missmsg(msgtype, &info, 0, err); ++ rt_missmsg(msgtype, &info, 0, err, fibnum); + } + } +@@ -575,5 +575,5 @@ + info.rti_info[RTAX_NETMASK] = netmask; + info.rti_info[RTAX_AUTHOR] = src; +- rt_missmsg(RTM_REDIRECT, &info, flags, error); ++ rt_missmsg(RTM_REDIRECT, &info, flags, error, fibnum); + } + +@@ -1464,5 +1464,5 @@ + */ + RT_LOCK(rt); +- rt_newaddrmsg(cmd, ifa, error, rt); ++ rt_newaddrmsg(cmd, ifa, error, rt, fibnum); + if (cmd == RTM_DELETE) { + /* +--- ./sys/net/route.h.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/net/route.h 2009-09-11 00:07:13.000000000 +0000 +@@ -350,6 +350,6 @@ + void rt_ifannouncemsg(struct ifnet *, int); + void rt_ifmsg(struct ifnet *); +-void rt_missmsg(int, struct rt_addrinfo *, int, int); +-void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *); ++void rt_missmsg(int, struct rt_addrinfo *, int, int, int); ++void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *, int); + void rt_newmaddrmsg(int, struct ifmultiaddr *); + int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *); +--- ./sys/netinet6/nd6_rtr.c.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/netinet6/nd6_rtr.c 2009-09-11 00:07:13.000000000 +0000 +@@ -444,5 +444,5 @@ + } + +- rt_missmsg(cmd, &info, rt->rt_flags, 0); ++ rt_missmsg(cmd, &info, rt->rt_flags, 0, -1); + } + +--- ./sys/netinet6/in6.c.orig 2009-06-10 10:31:11.000000000 +0000 ++++ ./sys/netinet6/in6.c 2009-09-11 00:09:37.000000000 +0000 +@@ -190,5 +190,5 @@ + } + +- rt_newaddrmsg(cmd, ifa, e, nrt); ++ rt_newaddrmsg(cmd, ifa, e, nrt, -1); + if (cmd == RTM_DELETE) + RTFREE_LOCKED(nrt); +--- ./sys/sys/mbuf.h.orig 2008-11-25 02:59:29.000000000 +0000 ++++ ./sys/sys/mbuf.h 2009-09-11 00:10:16.000000000 +0000 +@@ -852,5 +852,5 @@ + #define PACKET_TAG_MACLABEL (19 | MTAG_PERSISTENT) /* MAC label */ + #define PACKET_TAG_PF 21 /* PF + ALTQ information */ +-#define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ ++#define PACKET_TAG_RTSOCK 25 /* rtsock extra info */ + #define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */ + #define PACKET_TAG_CARP 28 /* CARP info */ |