RE: [PATCH 07/16] bsd: Modifications to shared IPv4/IPv6 code (eth,tcp,udp) for IPv6
The lltable stuff could probably have been split into another commit since it isn’t really related to anything else other than it is in the same file, but it was small/simple enough that I thought that wasn’t necessary. The rest of the change changes are enabling IPv6 stuff in the IPv4 code which was disabled/removed when the IPv4 code was ported to OSv. I just grouped these changes together to save myself some time and reduce number of parts in the patch set. -Charles From: Nadav Har'El Sent: Sunday, August 12, 2018 11:12 AM To: Myers, Charles Cc: Osv Dev Subject: Re: [PATCH 07/16] bsd: Modifications to shared IPv4/IPv6 code (eth,tcp,udp) for IPv6 The patch looks reasonable to me, but there are some things that I didn't understand how they fit in. For example, how do the changes bsd/sys/netinet/tcp_reass.cc related to some function for iterating link-level sockets? -- Nadav Har'El n...@scylladb.com<mailto:n...@scylladb.com> On Tue, Aug 7, 2018 at 5:49 AM, Charles Myers mailto:charles.my...@spirent.com>> wrote: lltable_foreach(), lltable_foreach_lle() added to support NETLINK sockets Signed-off-by: Charles Myers mailto:charles.my...@spirent.com>> --- bsd/sys/net/if_ethersubr.cc | 5 ++--- bsd/sys/net/if_llatbl.cc| 47 ++--- bsd/sys/net/if_llatbl.h | 13 bsd/sys/netinet/tcp_lro.cc | 4 ++-- bsd/sys/netinet/tcp_lro.h | 15 +++-- bsd/sys/netinet/tcp_reass.cc| 4 ++-- bsd/sys/netinet/tcp_subr.cc | 6 -- bsd/sys/netinet/tcp_syncache.cc | 3 +-- bsd/sys/netinet/udp_usrreq.cc | 2 +- 9 files changed, 78 insertions(+), 21 deletions(-) diff --git a/bsd/sys/net/if_ethersubr.cc b/bsd/sys/net/if_ethersubr.cc index 0443c83..d2c4fe9 100644 --- a/bsd/sys/net/if_ethersubr.cc +++ b/bsd/sys/net/if_ethersubr.cc @@ -1140,8 +1140,7 @@ ether_resolvemulti(struct ifnet *ifp, struct bsd_sockaddr **llsa, } if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) return EADDRNOTAVAIL; - sdl = malloc(sizeof *sdl, M_IFMADDR, - M_NOWAIT|M_ZERO); + sdl = (struct bsd_sockaddr_dl *) calloc(1, sizeof *sdl); if (sdl == NULL) return (ENOMEM); sdl->sdl_len = sizeof *sdl; @@ -1149,7 +1148,7 @@ ether_resolvemulti(struct ifnet *ifp, struct bsd_sockaddr **llsa, sdl->sdl_index = ifp->if_index; sdl->sdl_type = IFT_ETHER; sdl->sdl_alen = ETHER_ADDR_LEN; - e_addr = LLADDR(sdl); + e_addr = (u_char*)LLADDR(sdl); ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr); *llsa = (struct bsd_sockaddr *)sdl; return 0; diff --git a/bsd/sys/net/if_llatbl.cc b/bsd/sys/net/if_llatbl.cc index 869c552..1bc7ca2 100644 --- a/bsd/sys/net/if_llatbl.cc +++ b/bsd/sys/net/if_llatbl.cc @@ -40,9 +40,9 @@ #include #include #include -#if 0 -#include -#include +#ifdef INET6 +#include +#include #endif MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables"); @@ -497,3 +497,44 @@ DB_SHOW_ALL_COMMAND(lltables, db_show_all_lltables) } } #endif + +/* + * Iterate over all lltables + */ +int lltable_foreach(int (*func)(struct lltable *llt, void *cbdata), void *cbdata) +{ + struct lltable *llt; + int error = 0; + + LLTABLE_RLOCK(); + SLIST_FOREACH(llt, &V_lltables, llt_link) { + if ((error = func(llt, cbdata)) != 0) + break; + } + LLTABLE_RUNLOCK(); + + return error; +} + +/* + * Iterate over all llentries in the lltable + */ +int lltable_foreach_lle(struct lltable *llt, int (*func)(struct lltable *llt, struct llentry *lle, void *cbdata), void *cbdata) +{ + struct llentry *lle; + int i; + int error = 0; + + for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { + LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { + /* skip deleted entries */ + if ((lle->la_flags & LLE_DELETED) == LLE_DELETED) + continue; + if ((error = func(llt, lle, cbdata)) != 0) + break; + } + } + + return error; +} + diff --git a/bsd/sys/net/if_llatbl.h b/bsd/sys/net/if_llatbl.h index 1cac880..6e0985e 100644 --- a/bsd/sys/net/if_llatbl.h +++ b/bsd/sys/net/if_llatbl.h @@ -197,6 +197,17 @@ intlltable_sysctl_dumparp(int, struct sysctl_req *); size_t llentry_free(struct llentry *); struct llentry *llentry_alloc(struct ifnet *, struct lltable *, struct bsd_sockaddr_storage *); + +/* + * Iterate over all lltables + */ +int lltable_foreach(int (*func)(struct lltable *llt, void *cbdata), v
Re: [PATCH 07/16] bsd: Modifications to shared IPv4/IPv6 code (eth,tcp,udp) for IPv6
The patch looks reasonable to me, but there are some things that I didn't understand how they fit in. For example, how do the changes bsd/sys/netinet/tcp_reass.cc related to some function for iterating link-level sockets? -- Nadav Har'El n...@scylladb.com On Tue, Aug 7, 2018 at 5:49 AM, Charles Myers wrote: > lltable_foreach(), lltable_foreach_lle() added to support NETLINK sockets > > Signed-off-by: Charles Myers > --- > bsd/sys/net/if_ethersubr.cc | 5 ++--- > bsd/sys/net/if_llatbl.cc| 47 ++ > --- > bsd/sys/net/if_llatbl.h | 13 > bsd/sys/netinet/tcp_lro.cc | 4 ++-- > bsd/sys/netinet/tcp_lro.h | 15 +++-- > bsd/sys/netinet/tcp_reass.cc| 4 ++-- > bsd/sys/netinet/tcp_subr.cc | 6 -- > bsd/sys/netinet/tcp_syncache.cc | 3 +-- > bsd/sys/netinet/udp_usrreq.cc | 2 +- > 9 files changed, 78 insertions(+), 21 deletions(-) > > diff --git a/bsd/sys/net/if_ethersubr.cc b/bsd/sys/net/if_ethersubr.cc > index 0443c83..d2c4fe9 100644 > --- a/bsd/sys/net/if_ethersubr.cc > +++ b/bsd/sys/net/if_ethersubr.cc > @@ -1140,8 +1140,7 @@ ether_resolvemulti(struct ifnet *ifp, struct > bsd_sockaddr **llsa, > } > if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) > return EADDRNOTAVAIL; > - sdl = malloc(sizeof *sdl, M_IFMADDR, > - M_NOWAIT|M_ZERO); > + sdl = (struct bsd_sockaddr_dl *) calloc(1, sizeof *sdl); > if (sdl == NULL) > return (ENOMEM); > sdl->sdl_len = sizeof *sdl; > @@ -1149,7 +1148,7 @@ ether_resolvemulti(struct ifnet *ifp, struct > bsd_sockaddr **llsa, > sdl->sdl_index = ifp->if_index; > sdl->sdl_type = IFT_ETHER; > sdl->sdl_alen = ETHER_ADDR_LEN; > - e_addr = LLADDR(sdl); > + e_addr = (u_char*)LLADDR(sdl); > ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr); > *llsa = (struct bsd_sockaddr *)sdl; > return 0; > diff --git a/bsd/sys/net/if_llatbl.cc b/bsd/sys/net/if_llatbl.cc > index 869c552..1bc7ca2 100644 > --- a/bsd/sys/net/if_llatbl.cc > +++ b/bsd/sys/net/if_llatbl.cc > @@ -40,9 +40,9 @@ > #include > #include > #include > -#if 0 > -#include > -#include > +#ifdef INET6 > +#include > +#include > #endif > > MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables"); > @@ -497,3 +497,44 @@ DB_SHOW_ALL_COMMAND(lltables, db_show_all_lltables) > } > } > #endif > + > +/* > + * Iterate over all lltables > + */ > +int lltable_foreach(int (*func)(struct lltable *llt, void *cbdata), void > *cbdata) > +{ > + struct lltable *llt; > + int error = 0; > + > + LLTABLE_RLOCK(); > + SLIST_FOREACH(llt, &V_lltables, llt_link) { > + if ((error = func(llt, cbdata)) != 0) > + break; > + } > + LLTABLE_RUNLOCK(); > + > + return error; > +} > + > +/* > + * Iterate over all llentries in the lltable > + */ > +int lltable_foreach_lle(struct lltable *llt, int (*func)(struct lltable > *llt, struct llentry *lle, void *cbdata), void *cbdata) > +{ > + struct llentry *lle; > + int i; > + int error = 0; > + > + for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { > + LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { > + /* skip deleted entries */ > + if ((lle->la_flags & LLE_DELETED) == LLE_DELETED) > + continue; > + if ((error = func(llt, lle, cbdata)) != 0) > + break; > + } > + } > + > + return error; > +} > + > diff --git a/bsd/sys/net/if_llatbl.h b/bsd/sys/net/if_llatbl.h > index 1cac880..6e0985e 100644 > --- a/bsd/sys/net/if_llatbl.h > +++ b/bsd/sys/net/if_llatbl.h > @@ -197,6 +197,17 @@ intlltable_sysctl_dumparp(int, struct > sysctl_req *); > size_t llentry_free(struct llentry *); > struct llentry *llentry_alloc(struct ifnet *, struct lltable *, > struct bsd_sockaddr_storage *); > + > +/* > + * Iterate over all lltables > + */ > +int lltable_foreach(int (*func)(struct lltable *llt, void *cbdata), void > *cbdata); > + > +/* > + * Iterate over all llentries in the lltable > + */ > +int lltable_foreach_lle(struct lltable *llt, int (*func)(struct lltable > *llt, struct llentry *lle, void *cbdata), void *cbdata); > + > __END_DECLS > > /* > @@ -216,4 +227,6 @@ lla_lookup_fast(struct lltable *llt, u_int flags, > const struct bsd_sockaddr *l3a > } > > intlla_rt_output(struct rt_msghdr *, struct rt_addrinfo *); > + > + > #endif /* _NET_IF_LLATBL_H_ */ > diff --git a/bsd/sys/netinet/tcp_lro.cc b/bsd/sys/netinet/tcp_lro.cc > index da966f5..e4b83ad 100644 > --- a/bsd/sys/netinet/tcp_lro.cc > +++ b/bsd/sys/netinet/tcp_lro.cc >
[PATCH 07/16] bsd: Modifications to shared IPv4/IPv6 code (eth,tcp,udp) for IPv6
lltable_foreach(), lltable_foreach_lle() added to support NETLINK sockets Signed-off-by: Charles Myers --- bsd/sys/net/if_ethersubr.cc | 5 ++--- bsd/sys/net/if_llatbl.cc| 47 ++--- bsd/sys/net/if_llatbl.h | 13 bsd/sys/netinet/tcp_lro.cc | 4 ++-- bsd/sys/netinet/tcp_lro.h | 15 +++-- bsd/sys/netinet/tcp_reass.cc| 4 ++-- bsd/sys/netinet/tcp_subr.cc | 6 -- bsd/sys/netinet/tcp_syncache.cc | 3 +-- bsd/sys/netinet/udp_usrreq.cc | 2 +- 9 files changed, 78 insertions(+), 21 deletions(-) diff --git a/bsd/sys/net/if_ethersubr.cc b/bsd/sys/net/if_ethersubr.cc index 0443c83..d2c4fe9 100644 --- a/bsd/sys/net/if_ethersubr.cc +++ b/bsd/sys/net/if_ethersubr.cc @@ -1140,8 +1140,7 @@ ether_resolvemulti(struct ifnet *ifp, struct bsd_sockaddr **llsa, } if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) return EADDRNOTAVAIL; - sdl = malloc(sizeof *sdl, M_IFMADDR, - M_NOWAIT|M_ZERO); + sdl = (struct bsd_sockaddr_dl *) calloc(1, sizeof *sdl); if (sdl == NULL) return (ENOMEM); sdl->sdl_len = sizeof *sdl; @@ -1149,7 +1148,7 @@ ether_resolvemulti(struct ifnet *ifp, struct bsd_sockaddr **llsa, sdl->sdl_index = ifp->if_index; sdl->sdl_type = IFT_ETHER; sdl->sdl_alen = ETHER_ADDR_LEN; - e_addr = LLADDR(sdl); + e_addr = (u_char*)LLADDR(sdl); ETHER_MAP_IPV6_MULTICAST(&sin6->sin6_addr, e_addr); *llsa = (struct bsd_sockaddr *)sdl; return 0; diff --git a/bsd/sys/net/if_llatbl.cc b/bsd/sys/net/if_llatbl.cc index 869c552..1bc7ca2 100644 --- a/bsd/sys/net/if_llatbl.cc +++ b/bsd/sys/net/if_llatbl.cc @@ -40,9 +40,9 @@ #include #include #include -#if 0 -#include -#include +#ifdef INET6 +#include +#include #endif MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables"); @@ -497,3 +497,44 @@ DB_SHOW_ALL_COMMAND(lltables, db_show_all_lltables) } } #endif + +/* + * Iterate over all lltables + */ +int lltable_foreach(int (*func)(struct lltable *llt, void *cbdata), void *cbdata) +{ + struct lltable *llt; + int error = 0; + + LLTABLE_RLOCK(); + SLIST_FOREACH(llt, &V_lltables, llt_link) { + if ((error = func(llt, cbdata)) != 0) + break; + } + LLTABLE_RUNLOCK(); + + return error; +} + +/* + * Iterate over all llentries in the lltable + */ +int lltable_foreach_lle(struct lltable *llt, int (*func)(struct lltable *llt, struct llentry *lle, void *cbdata), void *cbdata) +{ + struct llentry *lle; + int i; + int error = 0; + + for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { + LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { + /* skip deleted entries */ + if ((lle->la_flags & LLE_DELETED) == LLE_DELETED) + continue; + if ((error = func(llt, lle, cbdata)) != 0) + break; + } + } + + return error; +} + diff --git a/bsd/sys/net/if_llatbl.h b/bsd/sys/net/if_llatbl.h index 1cac880..6e0985e 100644 --- a/bsd/sys/net/if_llatbl.h +++ b/bsd/sys/net/if_llatbl.h @@ -197,6 +197,17 @@ intlltable_sysctl_dumparp(int, struct sysctl_req *); size_t llentry_free(struct llentry *); struct llentry *llentry_alloc(struct ifnet *, struct lltable *, struct bsd_sockaddr_storage *); + +/* + * Iterate over all lltables + */ +int lltable_foreach(int (*func)(struct lltable *llt, void *cbdata), void *cbdata); + +/* + * Iterate over all llentries in the lltable + */ +int lltable_foreach_lle(struct lltable *llt, int (*func)(struct lltable *llt, struct llentry *lle, void *cbdata), void *cbdata); + __END_DECLS /* @@ -216,4 +227,6 @@ lla_lookup_fast(struct lltable *llt, u_int flags, const struct bsd_sockaddr *l3a } intlla_rt_output(struct rt_msghdr *, struct rt_addrinfo *); + + #endif /* _NET_IF_LLATBL_H_ */ diff --git a/bsd/sys/netinet/tcp_lro.cc b/bsd/sys/netinet/tcp_lro.cc index da966f5..e4b83ad 100644 --- a/bsd/sys/netinet/tcp_lro.cc +++ b/bsd/sys/netinet/tcp_lro.cc @@ -44,7 +44,7 @@ #include #include -#if 0 +#ifdef INET6 #include #endif @@ -53,7 +53,7 @@ #include #include -#if 0 +#ifdef INET6 #include #endif diff --git a/bsd/sys/netinet/tcp_lro.h b/bsd/sys/netinet/tcp_lro.h index ca81237..63379d5 100644 --- a/bsd/sys/netinet/tcp_lro.h +++ b/bsd/sys/netinet/tcp_lro.h @@ -39,18 +39,21 @@ struct lro_entry struct mbuf *m_tail; union { struct ip *ip4; - /* FIXME: OSv - uncomment when we have IPv6 */ - /* struct ip6_hdr *ip6; */ +#ifdef INE