diff options
author | qingli <qingli@FreeBSD.org> | 2010-03-16 17:59:12 +0000 |
---|---|---|
committer | qingli <qingli@FreeBSD.org> | 2010-03-16 17:59:12 +0000 |
commit | 4ff4954e4e9b86c057c52b9d83cd9b7ba9517e0c (patch) | |
tree | 7561e70ebfe1fe869d105399b20f5295a570ccd0 /sys/net | |
parent | 61b55f12a23899ec936af095b7b050085cf02e8d (diff) | |
download | FreeBSD-src-4ff4954e4e9b86c057c52b9d83cd9b7ba9517e0c.zip FreeBSD-src-4ff4954e4e9b86c057c52b9d83cd9b7ba9517e0c.tar.gz |
Verify interface up status using its link state only
if the interface has such capability. The interface
capability flag indicates whether such capability
exists. This approach is much more backward compatible.
Physical device driver changes will be part of another
commit.
Also updated the ifconfig utility to show the LINKSTATE
capability if present.
Reviewed by: rwatson, imp, juli
MFC after: 3 days
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.h | 1 | ||||
-rw-r--r-- | sys/net/if_tap.c | 2 | ||||
-rw-r--r-- | sys/net/if_tun.c | 2 | ||||
-rw-r--r-- | sys/net/route.h | 3 |
4 files changed, 6 insertions, 2 deletions
diff --git a/sys/net/if.h b/sys/net/if.h index e226654..ae0daf5 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -219,6 +219,7 @@ struct if_data { #define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */ #define IFCAP_POLLING_NOCOUNT 0x20000 /* polling ticks cannot be fragmented */ #define IFCAP_VLAN_HWTSO 0x40000 /* can do IFCAP_TSO on VLANs */ +#define IFCAP_LINKSTATE 0x80000 /* the runtime link state is dynamic */ #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 9123e8c..eb81e81 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -443,6 +443,8 @@ tapcreate(struct cdev *dev) ifp->if_mtu = ETHERMTU; ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST); ifp->if_snd.ifq_maxlen = ifqmaxlen; + ifp->if_capabilities |= IFCAP_LINKSTATE; + ifp->if_capenable |= IFCAP_LINKSTATE; dev->si_drv1 = tp; tp->tap_dev = dev; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 1fa02ac..1da63ba 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -386,6 +386,8 @@ tuncreate(const char *name, struct cdev *dev) ifp->if_snd.ifq_drv_maxlen = 0; IFQ_SET_READY(&ifp->if_snd); knlist_init_mtx(&sc->tun_rsel.si_note, NULL); + ifp->if_capabilities |= IFCAP_LINKSTATE; + ifp->if_capenable |= IFCAP_LINKSTATE; if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); diff --git a/sys/net/route.h b/sys/net/route.h index 8c35678..bb5def3 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -319,8 +319,7 @@ struct rt_addrinfo { #ifdef _KERNEL -#define RT_LINK_IS_UP(ifp) (((ifp)->if_flags & \ - (IFF_LOOPBACK | IFF_POINTOPOINT)) \ +#define RT_LINK_IS_UP(ifp) (!((ifp)->if_capabilities & IFCAP_LINKSTATE) \ || (ifp)->if_link_state == LINK_STATE_UP) #define RT_LOCK_INIT(_rt) \ |