aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2012-12-27 18:49:39 -0500
committerDavid S. Miller <davem@davemloft.net>2012-12-28 18:24:18 -0500
commit9a57247f31e361f80508c40363366222dbbb6aa5 (patch)
treee125345af6ec8fc6e2788fc694141a38feb6f249
parentfdae0fde5352790030d89edd09f1b43b9bed97f8 (diff)
rtnl: expose carrier value with possibility to set it
Signed-off-by: Jiri Pirko <jiri@resnulli.us> Acked-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/networking/operstates.txt4
-rw-r--r--include/uapi/linux/if_link.h1
-rw-r--r--net/core/rtnetlink.c10
3 files changed, 15 insertions, 0 deletions
diff --git a/Documentation/networking/operstates.txt b/Documentation/networking/operstates.txt
index 1a77a3cfae54..97694572338b 100644
--- a/Documentation/networking/operstates.txt
+++ b/Documentation/networking/operstates.txt
@@ -88,6 +88,10 @@ set this flag. On netif_carrier_off(), the scheduler stops sending
88packets. The name 'carrier' and the inversion are historical, think of 88packets. The name 'carrier' and the inversion are historical, think of
89it as lower layer. 89it as lower layer.
90 90
91Note that for certain kind of soft-devices, which are not managing any
92real hardware, there is possible to set this bit from userpsace.
93One should use TVL IFLA_CARRIER to do so.
94
91netif_carrier_ok() can be used to query that bit. 95netif_carrier_ok() can be used to query that bit.
92 96
93__LINK_STATE_DORMANT, maps to IFF_DORMANT: 97__LINK_STATE_DORMANT, maps to IFF_DORMANT:
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 60f3b6b90602..c4edfe11f1f7 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -142,6 +142,7 @@ enum {
142#define IFLA_PROMISCUITY IFLA_PROMISCUITY 142#define IFLA_PROMISCUITY IFLA_PROMISCUITY
143 IFLA_NUM_TX_QUEUES, 143 IFLA_NUM_TX_QUEUES,
144 IFLA_NUM_RX_QUEUES, 144 IFLA_NUM_RX_QUEUES,
145 IFLA_CARRIER,
145 __IFLA_MAX 146 __IFLA_MAX
146}; 147};
147 148
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 1868625af25e..2ef7a56ba117 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -780,6 +780,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
780 + nla_total_size(4) /* IFLA_MTU */ 780 + nla_total_size(4) /* IFLA_MTU */
781 + nla_total_size(4) /* IFLA_LINK */ 781 + nla_total_size(4) /* IFLA_LINK */
782 + nla_total_size(4) /* IFLA_MASTER */ 782 + nla_total_size(4) /* IFLA_MASTER */
783 + nla_total_size(1) /* IFLA_CARRIER */
783 + nla_total_size(4) /* IFLA_PROMISCUITY */ 784 + nla_total_size(4) /* IFLA_PROMISCUITY */
784 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */ 785 + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
785 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */ 786 + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
@@ -909,6 +910,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
909 nla_put_u32(skb, IFLA_LINK, dev->iflink)) || 910 nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
910 (dev->master && 911 (dev->master &&
911 nla_put_u32(skb, IFLA_MASTER, dev->master->ifindex)) || 912 nla_put_u32(skb, IFLA_MASTER, dev->master->ifindex)) ||
913 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
912 (dev->qdisc && 914 (dev->qdisc &&
913 nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) || 915 nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) ||
914 (dev->ifalias && 916 (dev->ifalias &&
@@ -1108,6 +1110,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1108 [IFLA_MTU] = { .type = NLA_U32 }, 1110 [IFLA_MTU] = { .type = NLA_U32 },
1109 [IFLA_LINK] = { .type = NLA_U32 }, 1111 [IFLA_LINK] = { .type = NLA_U32 },
1110 [IFLA_MASTER] = { .type = NLA_U32 }, 1112 [IFLA_MASTER] = { .type = NLA_U32 },
1113 [IFLA_CARRIER] = { .type = NLA_U8 },
1111 [IFLA_TXQLEN] = { .type = NLA_U32 }, 1114 [IFLA_TXQLEN] = { .type = NLA_U32 },
1112 [IFLA_WEIGHT] = { .type = NLA_U32 }, 1115 [IFLA_WEIGHT] = { .type = NLA_U32 },
1113 [IFLA_OPERSTATE] = { .type = NLA_U8 }, 1116 [IFLA_OPERSTATE] = { .type = NLA_U8 },
@@ -1438,6 +1441,13 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
1438 modified = 1; 1441 modified = 1;
1439 } 1442 }
1440 1443
1444 if (tb[IFLA_CARRIER]) {
1445 err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER]));
1446 if (err)
1447 goto errout;
1448 modified = 1;
1449 }
1450
1441 if (tb[IFLA_TXQLEN]) 1451 if (tb[IFLA_TXQLEN])
1442 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); 1452 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
1443 1453