Turning the IPv6 forwarding path MP-safe implies, in a first step, to
defer local delivery to a context serialized by the KERNEL_LOCK(). This
is the same design as for IPv4.
In order to keep discarding TCP-over-Anycast I'm using an mbuf(9) flag
to remember that a packet has been received on such address. This is
necessary because we do not want to pass extra arguments when enqueuing
an mbuf.
This reuse the recently unused M_FILDROP.
ok?
Index: sys/sys/mbuf.h
===================================================================
RCS file: /cvs/src/sys/sys/mbuf.h,v
retrieving revision 1.215
diff -u -p -r1.215 mbuf.h
--- sys/sys/mbuf.h 13 Jun 2016 21:24:43 -0000 1.215
+++ sys/sys/mbuf.h 12 Jul 2016 09:35:58 -0000
@@ -184,7 +184,7 @@ struct mbuf {
/* mbuf pkthdr flags, also in m_flags */
#define M_VLANTAG 0x0020 /* ether_vtag is valid */
#define M_LOOP 0x0040 /* for Mbuf statistics */
-#define M_FILDROP 0x0080 /* dropped by bpf filter */
+#define M_ACAST 0x0080 /* received as IPv6 anycast */
#define M_BCAST 0x0100 /* send/received as link-level
broadcast */
#define M_MCAST 0x0200 /* send/received as link-level
multicast */
#define M_CONF 0x0400 /* payload was encrypted (ESP-transport) */
@@ -197,13 +197,13 @@ struct mbuf {
#ifdef _KERNEL
#define M_BITS \
("\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_EXTWR\5M_PROTO1\6M_VLANTAG\7M_LOOP" \
- "\10M_FILDROP\11M_BCAST\12M_MCAST\13M_CONF\14M_AUTH\15M_TUNNEL" \
+ "\10M_ACAST\11M_BCAST\12M_MCAST\13M_CONF\14M_AUTH\15M_TUNNEL" \
"\16M_ZEROIZE\17M_COMP\20M_LINK0")
#endif
/* flags copied when copying m_pkthdr */
#define M_COPYFLAGS
(M_PKTHDR|M_EOR|M_PROTO1|M_BCAST|M_MCAST|M_CONF|M_COMP|\
- M_AUTH|M_LOOP|M_TUNNEL|M_LINK0|M_VLANTAG|M_FILDROP|\
+ M_AUTH|M_LOOP|M_TUNNEL|M_LINK0|M_VLANTAG|M_ACAST|\
M_ZEROIZE)
/* Checksumming flags */
Index: sys/netinet6/ip6_input.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.162
diff -u -p -r1.162 ip6_input.c
--- sys/netinet6/ip6_input.c 6 Jul 2016 15:50:00 -0000 1.162
+++ sys/netinet6/ip6_input.c 12 Jul 2016 09:37:16 -0000
@@ -197,7 +197,7 @@ ip6_input(struct mbuf *m)
#if NPF > 0
struct in6_addr odst;
#endif
- int srcrt = 0, isanycast = 0;
+ int srcrt = 0;
u_int rtableid = 0;
ifp = if_get(m->m_pkthdr.ph_ifidx);
@@ -456,7 +456,7 @@ ip6_input(struct mbuf *m)
struct in6_ifaddr *ia6 =
ifatoia6(ip6_forward_rt.ro_rt->rt_ifa);
if (ia6->ia6_flags & IN6_IFF_ANYCAST)
- isanycast = 1;
+ m->m_flags |= M_ACAST;
/*
* packets to a tentative, duplicated, or somehow invalid
* address must not be accepted.
@@ -558,7 +558,7 @@ ip6_input(struct mbuf *m)
}
/* draft-itojun-ipv6-tcp-to-anycast */
- if (isanycast && nxt == IPPROTO_TCP) {
+ if (ISSET(m->m_flags, M_ACAST) && (nxt == IPPROTO_TCP)) {
if (m->m_len >= sizeof(struct ip6_hdr)) {
icmp6_error(m, ICMP6_DST_UNREACH,
ICMP6_DST_UNREACH_ADDR,
Index: share/man/man9/mbuf.9
===================================================================
RCS file: /cvs/src/share/man/man9/mbuf.9,v
retrieving revision 1.99
diff -u -p -r1.99 mbuf.9
--- share/man/man9/mbuf.9 8 Apr 2016 10:01:12 -0000 1.99
+++ share/man/man9/mbuf.9 12 Jul 2016 09:50:48 -0000
@@ -294,10 +294,8 @@ protocol-specific.
variable is valid.
.It Dv M_LOOP
for mbuf statistics.
-.It Dv M_FILDROP
-dropped by
-.Xr bpf 4
-filter.
+.It Dv M_ACAST
+received as IPv6 anycast.
.It Dv M_BCAST
packet send/received as link-level broadcast.
.It Dv M_MCAST