summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2004-09-01 18:22:14 +0000
committerbrooks <brooks@FreeBSD.org>2004-09-01 18:22:14 +0000
commitba918da2a51c9e7f2352076e0fbab5f3a82f8104 (patch)
tree0fdc8d4c7e4a1a23a7a359dc70fbd001b86bbe22
parent7f91bb5d9aea96d133ac63690a8e5483654c4503 (diff)
downloadFreeBSD-src-ba918da2a51c9e7f2352076e0fbab5f3a82f8104.zip
FreeBSD-src-ba918da2a51c9e7f2352076e0fbab5f3a82f8104.tar.gz
Use a spare byte in struct if_data to store the structure size without
increasing it. Add code to ifconfig to use this size to find the sockaddr_dl after the struct if_data in the routing message. This allows struct if_data to grow (up to 255 bytes) without breaking ifconfig. Submitted by: peter
-rw-r--r--sbin/ifconfig/ifconfig.c5
-rw-r--r--sys/net/if.c1
-rw-r--r--sys/net/if.h1
3 files changed, 6 insertions, 1 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 64e8882..858b8a4 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -585,7 +585,10 @@ retry:
ifm = (struct if_msghdr *)next;
if (ifm->ifm_type == RTM_IFINFO) {
- sdl = (struct sockaddr_dl *)(ifm + 1);
+ if (ifm->ifm_data.ifi_datalen == 0)
+ ifm->ifm_data.ifi_datalen = sizeof(struct if_data);
+ sdl = (struct sockaddr_dl *)((char *)ifm + sizeof(struct if_msghdr) -
+ sizeof(struct if_data) + ifm->ifm_data.ifi_datalen);
flags = ifm->ifm_flags;
} else {
fprintf(stderr, "out of sync parsing NET_RT_IFLIST\n");
diff --git a/sys/net/if.c b/sys/net/if.c
index 0bb5389..ef48f1e 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -399,6 +399,7 @@ if_attach(struct ifnet *ifp)
if_index = ifp->if_index;
if (if_index >= if_indexlim)
if_grow();
+ ifp->if_data.ifi_datalen = sizeof(struct if_data);
ifnet_byindex(ifp->if_index) = ifp;
ifdev_byindex(ifp->if_index) = make_dev(&net_cdevsw,
diff --git a/sys/net/if.h b/sys/net/if.h
index 5a005c9..95389e6 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -85,6 +85,7 @@ struct if_data {
u_char ifi_link_state; /* current link state */
u_char ifi_recvquota; /* polling quota for receive intrs */
u_char ifi_xmitquota; /* polling quota for xmit intrs */
+ u_char ifi_datalen; /* length of this data struct */
u_long ifi_mtu; /* maximum transmission unit */
u_long ifi_metric; /* routing metric (external only) */
u_long ifi_baudrate; /* linespeed */
OpenPOWER on IntegriCloud