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
This commit is contained in:
Brooks Davis 2004-09-01 18:22:14 +00:00
parent 7e37fb1729
commit 9e734b4468
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134609
3 changed files with 6 additions and 1 deletions

View File

@ -585,7 +585,10 @@ main(int argc, char *argv[])
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");

View File

@ -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,

View File

@ -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 */