summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2004-12-31 19:46:27 +0000
committersam <sam@FreeBSD.org>2004-12-31 19:46:27 +0000
commit65cf57f523204a7d6cd5d3c0982549ff4e7a3c01 (patch)
tree8074773f4ec0bc591d617a3e62e72b59e4fadd5d /sbin
parent53f032a130f0a58cb1612d7aa7df15b94e0fc5d8 (diff)
downloadFreeBSD-src-65cf57f523204a7d6cd5d3c0982549ff4e7a3c01.zip
FreeBSD-src-65cf57f523204a7d6cd5d3c0982549ff4e7a3c01.tar.gz
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.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/af_link.c6
-rw-r--r--sbin/ifconfig/ifconfig.c29
-rw-r--r--sbin/ifconfig/ifconfig.h11
-rw-r--r--sbin/ifconfig/ifieee80211.c4
-rw-r--r--sbin/ifconfig/ifmac.c4
-rw-r--r--sbin/ifconfig/ifmedia.c4
-rw-r--r--sbin/ifconfig/ifvlan.c4
7 files changed, 44 insertions, 18 deletions
diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c
index 9daef02..57a1e27 100644
--- a/sbin/ifconfig/af_link.c
+++ b/sbin/ifconfig/af_link.c
@@ -36,6 +36,7 @@ static const char rcsid[] =
#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 struct ifreq link_ridreq;
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",
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 5fc2362..3ab1dce 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -102,7 +102,7 @@ static void usage(void);
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 @@ af_getbyfamily(int af)
}
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 @@ status(const struct afswtch *afp, int addrcount, struct sockaddr_dl *sdl,
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)
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
index 3de635c..d57517c 100644
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -85,8 +85,17 @@ enum {
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) */
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 4a90678..887e6da 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -1282,7 +1282,7 @@ printkey(const struct ieee80211req_key *ik)
}
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);
@@ -1792,7 +1792,7 @@ static struct cmd ieee80211_cmds[] = {
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
diff --git a/sbin/ifconfig/ifmac.c b/sbin/ifconfig/ifmac.c
index 4e5de09..bb02106 100644
--- a/sbin/ifconfig/ifmac.c
+++ b/sbin/ifconfig/ifmac.c
@@ -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 cmd mac_cmds[] = {
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
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
index 7deddd8..13773ce 100644
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -103,7 +103,7 @@ static struct ifmedia_description *get_subtype_desc(int,
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 cmd media_cmds[] = {
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
diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
index 59afb79..493f526 100644
--- a/sbin/ifconfig/ifvlan.c
+++ b/sbin/ifconfig/ifvlan.c
@@ -62,7 +62,7 @@ static int __tag = 0;
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 cmd vlan_cmds[] = {
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
OpenPOWER on IntegriCloud