lltable_foreach(), lltable_foreach_lle() added to support NETLINK sockets Signed-off-by: Charles Myers <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 <bsd/sys/net/route.h> #include <bsd/sys/net/vnet.h> #include <bsd/sys/netinet/if_ether.h> -#if 0 -#include <netinet6/in6_var.h> -#include <netinet6/nd6.h> +#ifdef INET6 +#include <bsd/sys/netinet6/in6_var.h> +#include <bsd/sys/netinet6/nd6.h> #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 @@ int lltable_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 } int lla_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 <bsd/sys/netinet/in_systm.h> #include <bsd/sys/netinet/in.h> -#if 0 +#ifdef INET6 #include <bsd/sys/netinet/ip6.h> #endif @@ -53,7 +53,7 @@ #include <bsd/sys/netinet/tcp.h> #include <bsd/sys/netinet/tcp_lro.h> -#if 0 +#ifdef INET6 #include <netinet6/ip6_var.h> #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 INET6 + struct ip6_hdr *ip6; +#endif } leip; union { in_addr_t s_ip4; - /* FIXME: OSv - uncomment when we have IPv6 */ - /* struct in6_addr s_ip6; */ +#ifdef INET6 + struct in6_addr s_ip6; +#endif } lesource; union { in_addr_t d_ip4; - /* FIXME: OSv - uncomment when we have IPv6 */ - /* struct in6_addr d_ip6; */ +#ifdef INET6 + struct in6_addr d_ip6; +#endif } ledest; uint16_t source_port; uint16_t dest_port; diff --git a/bsd/sys/netinet/tcp_reass.cc b/bsd/sys/netinet/tcp_reass.cc index d083cd1..eb25d34 100644 --- a/bsd/sys/netinet/tcp_reass.cc +++ b/bsd/sys/netinet/tcp_reass.cc @@ -52,7 +52,7 @@ #include <bsd/sys/netinet/ip_var.h> #include <bsd/sys/netinet/ip_options.h> -#if 0 +#ifdef INET6 #include <bsd/sys/netinet/ip6.h> #include <bsd/sys/netinet6/in6_pcb.h> #include <bsd/sys/netinet6/ip6_var.h> @@ -64,7 +64,7 @@ #include <bsd/sys/netinet/tcp_seq.h> #include <bsd/sys/netinet/tcp_timer.h> #include <bsd/sys/netinet/tcp_var.h> -#if 0 +#ifdef INET6 #include <bsd/sys/netinet6/tcp6_var.h> #endif diff --git a/bsd/sys/netinet/tcp_subr.cc b/bsd/sys/netinet/tcp_subr.cc index 42ed83d..5343af4 100644 --- a/bsd/sys/netinet/tcp_subr.cc +++ b/bsd/sys/netinet/tcp_subr.cc @@ -122,6 +122,7 @@ SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, "Default TCP Maximum Segment Size"); #endif +#if 0 #ifdef INET6 static int sysctl_net_inet_tcp_mss_v6_check(SYSCTL_HANDLER_ARGS) @@ -144,6 +145,7 @@ SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_V6MSSDFLT, v6mssdflt, &sysctl_net_inet_tcp_mss_v6_check, "I", "Default TCP Maximum Segment Size for IPv6"); #endif /* INET6 */ +#endif /* * Minimum MSS we accept and use. This prevents DoS attacks where @@ -466,7 +468,7 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, #ifdef INET6 isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); - ip6 = ipgen; + ip6 = (struct ip6_hdr *)ipgen; #endif /* INET6 */ ip = (struct ip *)ipgen; @@ -1733,7 +1735,7 @@ tcp_maxmtu6(struct in_conninfo *inc, int *flags) if (sro6.ro_rt->rt_rmx.rmx_mtu == 0) maxmtu = IN6_LINKMTU(sro6.ro_rt->rt_ifp); else - maxmtu = min(sro6.ro_rt->rt_rmx.rmx_mtu, + maxmtu = bsd_min(sro6.ro_rt->rt_rmx.rmx_mtu, IN6_LINKMTU(sro6.ro_rt->rt_ifp)); /* Report additional interface capabilities. */ diff --git a/bsd/sys/netinet/tcp_syncache.cc b/bsd/sys/netinet/tcp_syncache.cc index b1fb17c..e2773d4 100644 --- a/bsd/sys/netinet/tcp_syncache.cc +++ b/bsd/sys/netinet/tcp_syncache.cc @@ -692,8 +692,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) laddr6 = inp->in6p_laddr; if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) inp->in6p_laddr = sc->sc_inc.inc6_laddr; - if ((error = in6_pcbconnect_mbuf(inp, (struct bsd_sockaddr *)&sin6, - thread0.td_ucred, m)) != 0) { + if ((error = in6_pcbconnect_mbuf(inp, (struct bsd_sockaddr *)&sin6, 0, m)) != 0) { inp->in6p_laddr = laddr6; if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) { bsd_log(LOG_DEBUG, "%s; %s: in6_pcbconnect failed " diff --git a/bsd/sys/netinet/udp_usrreq.cc b/bsd/sys/netinet/udp_usrreq.cc index 441a065..2cce860 100644 --- a/bsd/sys/netinet/udp_usrreq.cc +++ b/bsd/sys/netinet/udp_usrreq.cc @@ -58,7 +58,7 @@ #include <bsd/sys/netinet/in_var.h> #include <bsd/sys/netinet/ip.h> #ifdef INET6 -#include <netinet/ip6.h> +#include <bsd/sys/netinet/ip6.h> #endif #include <bsd/sys/netinet/ip_icmp.h> #include <bsd/sys/netinet/icmp_var.h> -- 2.7.4 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.