Date: Mon, 20 Dec 2004 06:16:48 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 67376 for review Message-ID: <200412200616.iBK6Gmk8013280@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=67376 Change 67376 by sam@sam_ebb on 2004/12/20 06:16:12 Fix special status reporting. Prior to the reorg there was special-purpose code to display status for an interface for state that was not address-oriented. This status reporting was merged in to the address-oriented status reporting but did not work for link address reporting (as discovered with fwip interfaces). Correct this mis-merge and eliminate the bogus kludge that was used for link-level address reporting. o add an af_other_status method for an address family for reporting status of things like media, vlan, etc. o call the af_other_status methods after reporting address status for an interface o special-case link address status; when reporting all status for an interface invoke it specially prior to reporting af_other_status methods (since it requires the sockaddr_dl that is passed in to status separately from the rtmsg address state) o correct the calling convention for link address status; don't cast types, construct the proper parameter This fixes ifconfig on fwip interfaces. Affected files ... .. //depot/projects/wifi/sbin/ifconfig/Makefile#4 edit .. //depot/projects/wifi/sbin/ifconfig/af_link.c#3 edit .. //depot/projects/wifi/sbin/ifconfig/ifconfig.c#8 edit .. //depot/projects/wifi/sbin/ifconfig/ifconfig.h#7 edit .. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#32 edit .. //depot/projects/wifi/sbin/ifconfig/ifmac.c#6 edit .. //depot/projects/wifi/sbin/ifconfig/ifmedia.c#6 edit .. //depot/projects/wifi/sbin/ifconfig/ifvlan.c#6 edit Differences ... ==== //depot/projects/wifi/sbin/ifconfig/Makefile#4 (text+ko) ==== ==== //depot/projects/wifi/sbin/ifconfig/af_link.c#3 (text+ko) ==== @@ -36,6 +36,7 @@ #include <sys/ioctl.h> #include <sys/socket.h> #include <net/if.h> +#include <net/route.h> /* for RTX_IFA */ #include <err.h> #include <stdio.h> @@ -53,9 +54,10 @@ static void link_status(int s __unused, const struct rt_addrinfo *info) { - const struct sockaddr_dl *sdl = (const struct sockaddr_dl *)info; + const struct sockaddr_dl *sdl = + (const struct sockaddr_dl *) info->rti_info[RTAX_IFA]; - if (sdl->sdl_alen > 0) { + if (sdl != NULL && sdl->sdl_alen > 0) { if (sdl->sdl_type == IFT_ETHER && sdl->sdl_alen == ETHER_ADDR_LEN) printf("\tether %s\n", ==== //depot/projects/wifi/sbin/ifconfig/ifconfig.c#8 (text+ko) ==== @@ -102,7 +102,7 @@ static struct afswtch *af_getbyname(const char *name); static struct afswtch *af_getbyfamily(int af); -static void af_all_status(int, const struct rt_addrinfo *sdl); +static void af_other_status(int); static struct option *opts = NULL; @@ -391,18 +391,18 @@ } static void -af_all_status(int s, const struct rt_addrinfo *sdl) +af_other_status(int s) { struct afswtch *afp; uint8_t afmask[howmany(AF_MAX, NBBY)]; memset(afmask, 0, sizeof(afmask)); for (afp = afs; afp != NULL; afp = afp->af_next) { - if (afp->af_status == NULL) + if (afp->af_other_status == NULL) continue; if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af)) continue; - afp->af_status(s, sdl); + afp->af_other_status(s); setbit(afmask, afp->af_af); } } @@ -876,10 +876,25 @@ addrcount--; ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen); } + if (allfamilies || afp->af_af == AF_LINK) { + const struct afswtch *lafp; + + /* + * Hack; the link level address is received separately + * from the routing information so any address is not + * handled above. Cobble together an entry and invoke + * the status method specially. + */ + lafp = af_getbyname("lladdr"); + if (lafp != NULL) { + info.rti_info[RTAX_IFA] = (struct sockaddr *)sdl; + lafp->af_status(s, &info); + } + } if (allfamilies) - af_all_status(s, (const struct rt_addrinfo *) sdl); - else if (afp->af_status != NULL) - afp->af_status(s, (const struct rt_addrinfo *) sdl); + af_other_status(s); + else if (afp->af_other_status != NULL) + afp->af_other_status(s); strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name); if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0) ==== //depot/projects/wifi/sbin/ifconfig/ifconfig.h#7 (text+ko) ==== @@ -85,8 +85,17 @@ struct afswtch { const char *af_name; /* as given on cmd line, e.g. "inet" */ short af_af; /* AF_* */ - /* print status method */ + /* + * Status is handled one of two ways; if there is an + * address associated with the interface then the + * associated address family af_status method is invoked + * with the appropriate addressin info. Otherwise, if + * all possible info is to be displayed and af_other_status + * is defined then it is invoked after all address status + * is presented. + */ void (*af_status)(int, const struct rt_addrinfo *); + void (*af_other_status)(int); /* parse address method */ void (*af_getaddr)(const char *, int); /* parse prefix method (IPv6) */ ==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#32 (text+ko) ==== @@ -1271,7 +1271,7 @@ } static void -ieee80211_status(int s, const struct rt_addrinfo *info __unused) +ieee80211_status(int s) { static const uint8_t zerobssid[IEEE80211_ADDR_LEN]; enum ieee80211_opmode opmode = get80211opmode(s); @@ -1780,7 +1780,7 @@ static struct afswtch af_ieee80211 = { .af_name = "af_ieee80211", .af_af = AF_UNSPEC, - .af_status = ieee80211_status, + .af_other_status = ieee80211_status, }; static __constructor void ==== //depot/projects/wifi/sbin/ifconfig/ifmac.c#6 (text+ko) ==== @@ -50,7 +50,7 @@ #include "ifconfig.h" static void -maclabel_status(int s, const struct rt_addrinfo *info) +maclabel_status(int s) { struct ifreq ifr; mac_t label; @@ -105,7 +105,7 @@ static struct afswtch af_mac = { .af_name = "af_maclabel", .af_af = AF_UNSPEC, - .af_status = maclabel_status, + .af_other_status = maclabel_status, }; static __constructor void ==== //depot/projects/wifi/sbin/ifconfig/ifmedia.c#6 (text+ko) ==== @@ -103,7 +103,7 @@ struct ifmedia_type_to_subtype *ttos); static void -media_status(int s, const struct rt_addrinfo *info __unused) +media_status(int s) { struct ifmediareq ifmr; int *media_list, i; @@ -787,7 +787,7 @@ static struct afswtch af_media = { .af_name = "af_media", .af_af = AF_UNSPEC, - .af_status = media_status, + .af_other_status = media_status, }; static __constructor void ==== //depot/projects/wifi/sbin/ifconfig/ifvlan.c#6 (text+ko) ==== @@ -62,7 +62,7 @@ static int __have_tag = 0; static void -vlan_status(int s, const struct rt_addrinfo *info __unused) +vlan_status(int s) { struct vlanreq vreq; @@ -157,7 +157,7 @@ static struct afswtch af_vlan = { .af_name = "af_vlan", .af_af = AF_UNSPEC, - .af_status = vlan_status, + .af_other_status = vlan_status, }; static __constructor void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200412200616.iBK6Gmk8013280>