diff options
author | Stefan Rompf <stefan@loplof.de> | 2006-03-20 20:09:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-20 20:09:11 -0500 |
commit | b00055aacdb172c05067612278ba27265fcd05ce (patch) | |
tree | 4dbbee11b02d54cc0978113dfb07c53fdce17aa8 /include | |
parent | e843b9e1bec4a953d848a319da6a18ca5c667f55 (diff) |
[NET] core: add RFC2863 operstate
this patch adds a dormant flag to network devices, RFC2863 operstate derived
from these flags and possibility for userspace interaction. It allows drivers
to signal that a device is unusable for user traffic without disabling
queueing (and therefore the possibility for protocol establishment traffic to
flow) and a userspace supplicant (WPA, 802.1X) to mark a device unusable
without changes to the driver.
It is the result of our long discussion. However I must admit that it
represents what Jamal and I agreed on with compromises towards Krzysztof, but
Thomas and Krzysztof still disagree with some parts. Anyway I think it should
be applied.
Signed-off-by: Stefan Rompf <stefan@loplof.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/if.h | 26 | ||||
-rw-r--r-- | include/linux/netdevice.h | 35 | ||||
-rw-r--r-- | include/linux/rtnetlink.h | 2 |
3 files changed, 58 insertions, 5 deletions
diff --git a/include/linux/if.h b/include/linux/if.h index 12c6f6d157c3..374e20ad8b0d 100644 --- a/include/linux/if.h +++ b/include/linux/if.h | |||
@@ -33,7 +33,7 @@ | |||
33 | #define IFF_LOOPBACK 0x8 /* is a loopback net */ | 33 | #define IFF_LOOPBACK 0x8 /* is a loopback net */ |
34 | #define IFF_POINTOPOINT 0x10 /* interface is has p-p link */ | 34 | #define IFF_POINTOPOINT 0x10 /* interface is has p-p link */ |
35 | #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ | 35 | #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ |
36 | #define IFF_RUNNING 0x40 /* interface running and carrier ok */ | 36 | #define IFF_RUNNING 0x40 /* interface RFC2863 OPER_UP */ |
37 | #define IFF_NOARP 0x80 /* no ARP protocol */ | 37 | #define IFF_NOARP 0x80 /* no ARP protocol */ |
38 | #define IFF_PROMISC 0x100 /* receive all packets */ | 38 | #define IFF_PROMISC 0x100 /* receive all packets */ |
39 | #define IFF_ALLMULTI 0x200 /* receive all multicast packets*/ | 39 | #define IFF_ALLMULTI 0x200 /* receive all multicast packets*/ |
@@ -43,12 +43,16 @@ | |||
43 | 43 | ||
44 | #define IFF_MULTICAST 0x1000 /* Supports multicast */ | 44 | #define IFF_MULTICAST 0x1000 /* Supports multicast */ |
45 | 45 | ||
46 | #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING) | ||
47 | |||
48 | #define IFF_PORTSEL 0x2000 /* can set media type */ | 46 | #define IFF_PORTSEL 0x2000 /* can set media type */ |
49 | #define IFF_AUTOMEDIA 0x4000 /* auto media select active */ | 47 | #define IFF_AUTOMEDIA 0x4000 /* auto media select active */ |
50 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/ | 48 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/ |
51 | 49 | ||
50 | #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ | ||
51 | #define IFF_DORMANT 0x20000 /* driver signals dormant */ | ||
52 | |||
53 | #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|\ | ||
54 | IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) | ||
55 | |||
52 | /* Private (from user) interface flags (netdevice->priv_flags). */ | 56 | /* Private (from user) interface flags (netdevice->priv_flags). */ |
53 | #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ | 57 | #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ |
54 | #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ | 58 | #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ |
@@ -83,6 +87,22 @@ | |||
83 | #define IF_PROTO_FR_ETH_PVC 0x200B | 87 | #define IF_PROTO_FR_ETH_PVC 0x200B |
84 | #define IF_PROTO_RAW 0x200C /* RAW Socket */ | 88 | #define IF_PROTO_RAW 0x200C /* RAW Socket */ |
85 | 89 | ||
90 | /* RFC 2863 operational status */ | ||
91 | enum { | ||
92 | IF_OPER_UNKNOWN, | ||
93 | IF_OPER_NOTPRESENT, | ||
94 | IF_OPER_DOWN, | ||
95 | IF_OPER_LOWERLAYERDOWN, | ||
96 | IF_OPER_TESTING, | ||
97 | IF_OPER_DORMANT, | ||
98 | IF_OPER_UP, | ||
99 | }; | ||
100 | |||
101 | /* link modes */ | ||
102 | enum { | ||
103 | IF_LINK_MODE_DEFAULT, | ||
104 | IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */ | ||
105 | }; | ||
86 | 106 | ||
87 | /* | 107 | /* |
88 | * Device mapping structure. I'd just gone off and designed a | 108 | * Device mapping structure. I'd just gone off and designed a |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7fda03d338d1..b825be201bce 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -230,7 +230,8 @@ enum netdev_state_t | |||
230 | __LINK_STATE_SCHED, | 230 | __LINK_STATE_SCHED, |
231 | __LINK_STATE_NOCARRIER, | 231 | __LINK_STATE_NOCARRIER, |
232 | __LINK_STATE_RX_SCHED, | 232 | __LINK_STATE_RX_SCHED, |
233 | __LINK_STATE_LINKWATCH_PENDING | 233 | __LINK_STATE_LINKWATCH_PENDING, |
234 | __LINK_STATE_DORMANT, | ||
234 | }; | 235 | }; |
235 | 236 | ||
236 | 237 | ||
@@ -335,11 +336,14 @@ struct net_device | |||
335 | */ | 336 | */ |
336 | 337 | ||
337 | 338 | ||
338 | unsigned short flags; /* interface flags (a la BSD) */ | 339 | unsigned int flags; /* interface flags (a la BSD) */ |
339 | unsigned short gflags; | 340 | unsigned short gflags; |
340 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ | 341 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ |
341 | unsigned short padded; /* How much padding added by alloc_netdev() */ | 342 | unsigned short padded; /* How much padding added by alloc_netdev() */ |
342 | 343 | ||
344 | unsigned char operstate; /* RFC2863 operstate */ | ||
345 | unsigned char link_mode; /* mapping policy to operstate */ | ||
346 | |||
343 | unsigned mtu; /* interface MTU value */ | 347 | unsigned mtu; /* interface MTU value */ |
344 | unsigned short type; /* interface hardware type */ | 348 | unsigned short type; /* interface hardware type */ |
345 | unsigned short hard_header_len; /* hardware hdr length */ | 349 | unsigned short hard_header_len; /* hardware hdr length */ |
@@ -714,6 +718,10 @@ static inline void dev_put(struct net_device *dev) | |||
714 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on | 718 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on |
715 | * and _off may be called from IRQ context, but it is caller | 719 | * and _off may be called from IRQ context, but it is caller |
716 | * who is responsible for serialization of these calls. | 720 | * who is responsible for serialization of these calls. |
721 | * | ||
722 | * The name carrier is inappropriate, these functions should really be | ||
723 | * called netif_lowerlayer_*() because they represent the state of any | ||
724 | * kind of lower layer not just hardware media. | ||
717 | */ | 725 | */ |
718 | 726 | ||
719 | extern void linkwatch_fire_event(struct net_device *dev); | 727 | extern void linkwatch_fire_event(struct net_device *dev); |
@@ -729,6 +737,29 @@ extern void netif_carrier_on(struct net_device *dev); | |||
729 | 737 | ||
730 | extern void netif_carrier_off(struct net_device *dev); | 738 | extern void netif_carrier_off(struct net_device *dev); |
731 | 739 | ||
740 | static inline void netif_dormant_on(struct net_device *dev) | ||
741 | { | ||
742 | if (!test_and_set_bit(__LINK_STATE_DORMANT, &dev->state)) | ||
743 | linkwatch_fire_event(dev); | ||
744 | } | ||
745 | |||
746 | static inline void netif_dormant_off(struct net_device *dev) | ||
747 | { | ||
748 | if (test_and_clear_bit(__LINK_STATE_DORMANT, &dev->state)) | ||
749 | linkwatch_fire_event(dev); | ||
750 | } | ||
751 | |||
752 | static inline int netif_dormant(const struct net_device *dev) | ||
753 | { | ||
754 | return test_bit(__LINK_STATE_DORMANT, &dev->state); | ||
755 | } | ||
756 | |||
757 | |||
758 | static inline int netif_oper_up(const struct net_device *dev) { | ||
759 | return (dev->operstate == IF_OPER_UP || | ||
760 | dev->operstate == IF_OPER_UNKNOWN /* backward compat */); | ||
761 | } | ||
762 | |||
732 | /* Hot-plugging. */ | 763 | /* Hot-plugging. */ |
733 | static inline int netif_device_present(struct net_device *dev) | 764 | static inline int netif_device_present(struct net_device *dev) |
734 | { | 765 | { |
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index d50482ba27fe..edccefb45188 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h | |||
@@ -733,6 +733,8 @@ enum | |||
733 | #define IFLA_MAP IFLA_MAP | 733 | #define IFLA_MAP IFLA_MAP |
734 | IFLA_WEIGHT, | 734 | IFLA_WEIGHT, |
735 | #define IFLA_WEIGHT IFLA_WEIGHT | 735 | #define IFLA_WEIGHT IFLA_WEIGHT |
736 | IFLA_OPERSTATE, | ||
737 | IFLA_LINKMODE, | ||
736 | __IFLA_MAX | 738 | __IFLA_MAX |
737 | }; | 739 | }; |
738 | 740 | ||