diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c --- a/sys/compat/linux/linux.c +++ b/sys/compat/linux/linux.c @@ -468,9 +468,9 @@ } static u_int -linux_ifhwaddr_cb(void *arg, struct ifaddr *ifa, u_int count) +linux_ifhwaddr_cb(void *arg, struct sockaddr *sa, u_int count) { - struct sockaddr_dl *sdl = (struct sockaddr_dl *)ifa->ifa_addr; + struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa; struct l_sockaddr *lsa = arg; if (count > 0) diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -2120,7 +2120,7 @@ * Implement the SIOCGIFCONF ioctl */ static u_int -linux_ifconf_ifaddr_cb(void *arg, struct ifaddr *ifa, u_int count) +linux_ifconf_ifaddr_cb(void *arg, struct sockaddr *sa, u_int count) { #ifdef COMPAT_LINUX32 struct l_ifconf *ifc; @@ -2149,10 +2149,9 @@ }; static u_int -linux_ifconf_ifaddr_cb2(void *arg, struct ifaddr *ifa, u_int len) +linux_ifconf_ifaddr_cb2(void *arg, struct sockaddr *sa, u_int len) { struct linux_ifconfig_ifaddr_cb2_s *cbs = arg; - struct sockaddr *sa = ifa->ifa_addr; cbs->ifr.ifr_addr.sa_family = LINUX_AF_INET; memcpy(cbs->ifr.ifr_addr.sa_data, sa->sa_data, diff --git a/sys/dev/irdma/fbsd_kcompat.c b/sys/dev/irdma/fbsd_kcompat.c --- a/sys/dev/irdma/fbsd_kcompat.c +++ b/sys/dev/irdma/fbsd_kcompat.c @@ -183,19 +183,17 @@ } static u_int -irdma_add_ipv6_cb(void *arg, struct ifaddr *addr, u_int count __unused) +irdma_add_ipv6_cb(void *arg, struct sockaddr *sa, u_int count __unused) { struct irdma_device *iwdev = arg; - struct sockaddr_in6 *sin6; + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; u32 local_ipaddr6[4] = {}; char ip6buf[INET6_ADDRSTRLEN]; u8 *mac_addr; - sin6 = (struct sockaddr_in6 *)addr->ifa_addr; - irdma_copy_ip_ntohl(local_ipaddr6, (u32 *)&sin6->sin6_addr); - mac_addr = if_getlladdr(addr->ifa_ifp); + mac_addr = if_getlladdr(iwdev->netdev); printf("%s:%d IP=%s, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", __func__, __LINE__, @@ -222,18 +220,16 @@ } static u_int -irdma_add_ipv4_cb(void *arg, struct ifaddr *addr, u_int count __unused) +irdma_add_ipv4_cb(void *arg, struct sockaddr *sa, u_int count __unused) { struct irdma_device *iwdev = arg; - struct sockaddr_in *sin; + struct sockaddr_in *sin = (struct sockaddr_in *)sa; u32 ip_addr[4] = {}; uint8_t *mac_addr; - sin = (struct sockaddr_in *)addr->ifa_addr; - ip_addr[0] = ntohl(sin->sin_addr.s_addr); - mac_addr = if_getlladdr(addr->ifa_ifp); + mac_addr = if_getlladdr(iwdev->netdev); printf("%s:%d IP=%d.%d.%d.%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", __func__, __LINE__, diff --git a/sys/dev/irdma/irdma_cm.h b/sys/dev/irdma/irdma_cm.h --- a/sys/dev/irdma/irdma_cm.h +++ b/sys/dev/irdma/irdma_cm.h @@ -414,6 +414,7 @@ struct irdma_device *iwdev; struct irdma_cm_info *cm_info; struct irdma_cm_listener *cm_listen_node; + if_t curif; /* used by if_foreach_addr_type() iterator */ }; int irdma_schedule_cm_timer(struct irdma_cm_node *cm_node, diff --git a/sys/dev/irdma/irdma_cm.c b/sys/dev/irdma/irdma_cm.c --- a/sys/dev/irdma/irdma_cm.c +++ b/sys/dev/irdma/irdma_cm.c @@ -1718,14 +1718,14 @@ * on the adapter and adds the associated qhash filter */ static u_int -irdma_add_mqh_ifa_cb(void *arg, struct ifaddr *ifa, u_int count) +irdma_add_mqh_ifa_cb(void *arg, struct sockaddr *sa, u_int count) { struct irdma_add_mqh_cbs *cbs = arg; struct irdma_cm_listener *child_listen_node; struct irdma_cm_info *cm_info = cbs->cm_info; struct irdma_device *iwdev = cbs->iwdev; struct irdma_cm_listener *cm_parent_listen_node = cbs->cm_listen_node; - if_t ip_dev = ifa->ifa_ifp; + if_t ip_dev = cbs->curif; unsigned long flags; int ret; @@ -1746,23 +1746,23 @@ if (cm_info->ipv4) { irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM, "Allocating child CM Listener forIP=%x, vlan_id=%d, MAC=%x:%x:%x:%x:%x:%x\n", - ((struct sockaddr_in *)&ifa->ifa_addr)->sin_addr.s_addr, + ((struct sockaddr_in *)sa)->sin_addr.s_addr, rdma_vlan_dev_vlan_id(ip_dev), if_getlladdr(ip_dev)[0], if_getlladdr(ip_dev)[1], if_getlladdr(ip_dev)[2], if_getlladdr(ip_dev)[3], if_getlladdr(ip_dev)[4], if_getlladdr(ip_dev)[5]); child_listen_node->loc_addr[0] = - ntohl(((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr); + ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr); } else { irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM, "IP=%x:%x:%x:%x, vlan_id=%d, MAC=%x:%x:%x:%x:%x:%x\n", - IRDMA_PRINT_IP6(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr), + IRDMA_PRINT_IP6(&((struct sockaddr_in6 *)sa)->sin6_addr), rdma_vlan_dev_vlan_id(ip_dev), if_getlladdr(ip_dev)[0], if_getlladdr(ip_dev)[1], if_getlladdr(ip_dev)[2], if_getlladdr(ip_dev)[3], if_getlladdr(ip_dev)[4], if_getlladdr(ip_dev)[5]); irdma_copy_ip_ntohl(child_listen_node->loc_addr, - ((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr.__u6_addr.__u6_addr32); + ((struct sockaddr_in6 *)sa)->sin6_addr.__u6_addr.__u6_addr32); } memcpy(cm_info->loc_addr, child_listen_node->loc_addr, sizeof(cm_info->loc_addr)); @@ -1832,6 +1832,7 @@ ifp != iwdev->netdev) continue; + cbs.curif = ifp; if_addr_rlock(ifp); if (cm_info->ipv4) err = if_foreach_addr_type(ifp, AF_INET, irdma_add_mqh_ifa_cb, &cbs); diff --git a/sys/dev/qlnx/qlnxr/qlnxr_os.c b/sys/dev/qlnx/qlnxr/qlnxr_os.c --- a/sys/dev/qlnx/qlnxr/qlnxr_os.c +++ b/sys/dev/qlnx/qlnxr/qlnxr_os.c @@ -861,13 +861,13 @@ }; static u_int -qlnxr_add_ip_based_gid_cb(void *arg, struct ifaddr *ifa, u_int count) +qlnxr_add_ip_based_gid_cb(void *arg, struct sockaddr *sa, u_int count) { struct qlnx_cb_s *cba = arg; - QL_DPRINT12(cba->dev->ha, "IP address : %x\n", ((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr); + QL_DPRINT12(cba->dev->ha, "IP address : %x\n", ((struct sockaddr_in *)sa)->sin_addr.s_addr); ipv6_addr_set_v4mapped( - ((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr, + ((struct sockaddr_in *)sa)->sin_addr.s_addr, (struct in6_addr *)&cba->gid); QL_DPRINT12(cba->dev->ha, "gid generated : %llx\n", cba->gid); diff --git a/sys/net/if.c b/sys/net/if.c --- a/sys/net/if.c +++ b/sys/net/if.c @@ -4712,7 +4712,7 @@ CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != type) continue; - count += (*cb)(cb_arg, ifa, count); + count += (*cb)(cb_arg, ifa->ifa_addr, count); } NET_EPOCH_EXIT(et); diff --git a/sys/net/if_var.h b/sys/net/if_var.h --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -677,7 +677,7 @@ bool if_maddr_empty(if_t); struct ifaddr * if_getifaddr(const if_t ifp); -typedef u_int if_addr_cb_t(void *, struct ifaddr *, u_int); +typedef u_int if_addr_cb_t(void *, struct sockaddr *, u_int); u_int if_foreach_addr_type(if_t ifp, int type, if_addr_cb_t cb, void *cb_arg); typedef int (*if_foreach_cb_t)(if_t, void *); diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -1493,9 +1493,9 @@ } static u_int -bootpc_init_ifa_cb(void *arg, struct ifaddr *ifa, u_int count) +bootpc_init_ifa_cb(void *arg, struct sockaddr *sa, u_int count) { - struct sockaddr_dl *sdl = (struct sockaddr_dl *)ifa->ifa_addr; + struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa; if (count != 0) return (0); diff --git a/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c b/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c --- a/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c +++ b/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c @@ -158,13 +158,16 @@ if_t ndev; }; -STAILQ_HEAD(ipx_queue, ipx_entry); +struct ipx_ctx { + STAILQ_HEAD(, ipx_entry) head; + if_t curdev; +}; #ifdef INET static u_int -roce_gid_update_addr_ifa4_cb(void *arg, struct ifaddr *ifa, u_int count) +roce_gid_update_addr_ifa4_cb(void *arg, struct sockaddr *sa, u_int count) { - struct ipx_queue *ipx_head = arg; + struct ipx_ctx *ipx_ctx = arg; struct ipx_entry *entry; entry = kzalloc(sizeof(*entry), GFP_ATOMIC); @@ -173,9 +176,9 @@ "couldn't allocate entry for IPv4 update\n"); return (0); } - entry->ipx_addr.v4 = *((struct sockaddr_in *)ifa->ifa_addr); - entry->ndev = ifa->ifa_ifp; - STAILQ_INSERT_TAIL(ipx_head, entry, entry); + entry->ipx_addr.v4 = *((struct sockaddr_in *)sa); + entry->ndev = ipx_ctx->curdev; + STAILQ_INSERT_TAIL(&ipx_ctx->head, entry, entry); return (1); } @@ -183,9 +186,9 @@ #ifdef INET6 static u_int -roce_gid_update_addr_ifa6_cb(void *arg, struct ifaddr *ifa, u_int count) +roce_gid_update_addr_ifa6_cb(void *arg, struct sockaddr *sa, u_int count) { - struct ipx_queue *ipx_head = arg; + struct ipx_ctx *ipx_ctx = arg; struct ipx_entry *entry; entry = kzalloc(sizeof(*entry), GFP_ATOMIC); @@ -194,14 +197,14 @@ "couldn't allocate entry for IPv6 update\n"); return (0); } - entry->ipx_addr.v6 = *((struct sockaddr_in6 *)ifa->ifa_addr); - entry->ndev = ifa->ifa_ifp; + entry->ipx_addr.v6 = *((struct sockaddr_in6 *)sa); + entry->ndev = ipx_ctx->curdev; /* trash IPv6 scope ID */ sa6_recoverscope(&entry->ipx_addr.v6); entry->ipx_addr.v6.sin6_scope_id = 0; - STAILQ_INSERT_TAIL(ipx_head, entry, entry); + STAILQ_INSERT_TAIL(&ipx_ctx->head, entry, entry); return (1); } @@ -222,9 +225,9 @@ u16 index_num; int i; - struct ipx_queue ipx_head; - - STAILQ_INIT(&ipx_head); + struct ipx_ctx ipx_ctx = { + .head = STAILQ_HEAD_INITIALIZER(ipx_ctx.head) + }; /* make sure default GIDs are in */ default_gids = roce_gid_enum_netdev_default(device, port, ndev); @@ -242,11 +245,14 @@ } /* clone address information for IPv4 and IPv6 */ + ipx_ctx.curdev = ifp; #if defined(INET) - if_foreach_addr_type(ifp, AF_INET, roce_gid_update_addr_ifa4_cb, &ipx_head); + if_foreach_addr_type(ifp, AF_INET, + roce_gid_update_addr_ifa4_cb, &ipx_ctx); #endif #if defined(INET6) - if_foreach_addr_type(ifp, AF_INET6, roce_gid_update_addr_ifa6_cb, &ipx_head); + if_foreach_addr_type(ifp, AF_INET6, + roce_gid_update_addr_ifa6_cb, &ipx_ctx); #endif } NET_EPOCH_EXIT(et); @@ -255,7 +261,7 @@ VNET_LIST_RUNLOCK(); /* add missing GIDs, if any */ - STAILQ_FOREACH(entry, &ipx_head, entry) { + STAILQ_FOREACH(entry, &ipx_ctx.head, entry) { unsigned long gid_type_mask = roce_gid_type_mask_support(device, port); if (rdma_ip2gid(&entry->ipx_addr.sa[0], &gid) != 0) @@ -294,7 +300,7 @@ rdma_gid2ip(&ipx.sa[0], &gid); - STAILQ_FOREACH(entry, &ipx_head, entry) { + STAILQ_FOREACH(entry, &ipx_ctx.head, entry) { if (entry->ndev == ndev && memcmp(&entry->ipx_addr, &ipx, sizeof(ipx)) == 0) break; @@ -307,8 +313,8 @@ update_gid(GID_DEL, device, port, &gid, ndev); } - while ((entry = STAILQ_FIRST(&ipx_head))) { - STAILQ_REMOVE_HEAD(&ipx_head, entry); + while ((entry = STAILQ_FIRST(&ipx_ctx.head))) { + STAILQ_REMOVE_HEAD(&ipx_ctx.head, entry); kfree(entry); } } diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1119,7 +1119,7 @@ } static u_int -ipoib_match_dev_addr_cb(void *arg, struct ifaddr *ifa, u_int count) +ipoib_match_dev_addr_cb(void *arg, struct sockaddr *sa, u_int count) { struct sockaddr *addr = arg; @@ -1127,10 +1127,10 @@ if (count > 0) return (0); - if (ifa->ifa_addr->sa_len != addr->sa_len) + if (sa->sa_len != addr->sa_len) return (0); - if (memcmp(ifa->ifa_addr, addr, addr->sa_len) == 0) + if (memcmp(sa, addr, addr->sa_len) == 0) return (1); return (0); diff --git a/sys/ofed/include/rdma/ib_addr.h b/sys/ofed/include/rdma/ib_addr.h --- a/sys/ofed/include/rdma/ib_addr.h +++ b/sys/ofed/include/rdma/ib_addr.h @@ -227,10 +227,9 @@ } static u_int -_iboe_addr_get_sgid_ia_cb(void *arg, struct ifaddr *ifa, u_int count __unused) +_iboe_addr_get_sgid_ia_cb(void *arg, struct sockaddr *sa, u_int count __unused) { - ipv6_addr_set_v4mapped(((struct sockaddr_in *) - ifa->ifa_addr)->sin_addr.s_addr, + ipv6_addr_set_v4mapped(((struct sockaddr_in *)sa)->sin_addr.s_addr, (struct in6_addr *)arg); return (0); }