Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Add IF_OPER_TESTING

RFC 2863 defines the operational state testing. Add support for this
state, both as a IF_LINK_MODE_ and __LINK_STATE_.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andrew Lunn and committed by
David S. Miller
eec517cd 749d22e8

+65 -3
+41
include/linux/netdevice.h
··· 288 288 __LINK_STATE_NOCARRIER, 289 289 __LINK_STATE_LINKWATCH_PENDING, 290 290 __LINK_STATE_DORMANT, 291 + __LINK_STATE_TESTING, 291 292 }; 292 293 293 294 ··· 3905 3904 static inline bool netif_dormant(const struct net_device *dev) 3906 3905 { 3907 3906 return test_bit(__LINK_STATE_DORMANT, &dev->state); 3907 + } 3908 + 3909 + 3910 + /** 3911 + * netif_testing_on - mark device as under test. 3912 + * @dev: network device 3913 + * 3914 + * Mark device as under test (as per RFC2863). 3915 + * 3916 + * The testing state indicates that some test(s) must be performed on 3917 + * the interface. After completion, of the test, the interface state 3918 + * will change to up, dormant, or down, as appropriate. 3919 + */ 3920 + static inline void netif_testing_on(struct net_device *dev) 3921 + { 3922 + if (!test_and_set_bit(__LINK_STATE_TESTING, &dev->state)) 3923 + linkwatch_fire_event(dev); 3924 + } 3925 + 3926 + /** 3927 + * netif_testing_off - set device as not under test. 3928 + * @dev: network device 3929 + * 3930 + * Device is not in testing state. 3931 + */ 3932 + static inline void netif_testing_off(struct net_device *dev) 3933 + { 3934 + if (test_and_clear_bit(__LINK_STATE_TESTING, &dev->state)) 3935 + linkwatch_fire_event(dev); 3936 + } 3937 + 3938 + /** 3939 + * netif_testing - test if device is under test 3940 + * @dev: network device 3941 + * 3942 + * Check if device is under test 3943 + */ 3944 + static inline bool netif_testing(const struct net_device *dev) 3945 + { 3946 + return test_bit(__LINK_STATE_TESTING, &dev->state); 3908 3947 } 3909 3948 3910 3949
+1
include/uapi/linux/if.h
··· 178 178 enum { 179 179 IF_LINK_MODE_DEFAULT, 180 180 IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */ 181 + IF_LINK_MODE_TESTING, /* limit upward transition to testing */ 181 182 }; 182 183 183 184 /*
+5
net/core/dev.c
··· 9136 9136 else 9137 9137 netif_dormant_off(dev); 9138 9138 9139 + if (rootdev->operstate == IF_OPER_TESTING) 9140 + netif_testing_on(dev); 9141 + else 9142 + netif_testing_off(dev); 9143 + 9139 9144 if (netif_carrier_ok(rootdev)) 9140 9145 netif_carrier_on(dev); 9141 9146 else
+8 -1
net/core/rtnetlink.c
··· 829 829 switch (transition) { 830 830 case IF_OPER_UP: 831 831 if ((operstate == IF_OPER_DORMANT || 832 + operstate == IF_OPER_TESTING || 832 833 operstate == IF_OPER_UNKNOWN) && 833 - !netif_dormant(dev)) 834 + !netif_dormant(dev) && !netif_testing(dev)) 834 835 operstate = IF_OPER_UP; 836 + break; 837 + 838 + case IF_OPER_TESTING: 839 + if (operstate == IF_OPER_UP || 840 + operstate == IF_OPER_UNKNOWN) 841 + operstate = IF_OPER_TESTING; 835 842 break; 836 843 837 844 case IF_OPER_DORMANT: