From 0dbf2dbb1a6a7a70c74869f047cbedc67ddc3494 Mon Sep 17 00:00:00 2001 From: Eric Lemoine Date: Wed, 1 Sep 2004 23:13:01 -0700 Subject: [PATCH] [NET]: Allow get/set of dev->weight via netlink. Signed-off-by: David S. Miller --- include/linux/rtnetlink.h | 2 ++ net/core/rtnetlink.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index f92c35c07faca..388b3d3feb43f 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -565,6 +565,8 @@ enum #define IFLA_TXQLEN IFLA_TXQLEN IFLA_MAP, #define IFLA_MAP IFLA_MAP + IFLA_WEIGHT, +#define IFLA_WEIGHT IFLA_WEIGHT __IFLA_MAX }; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 4b50fabc39c57..24c9551c45b57 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -176,6 +176,11 @@ static int rtnetlink_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, RTA_PUT(skb, IFLA_TXQLEN, sizeof(txqlen), &txqlen); } + if (1) { + u32 weight = dev->weight; + RTA_PUT(skb, IFLA_WEIGHT, sizeof(weight), &weight); + } + if (1) { struct ifmap map = { .mem_start = dev->mem_start, @@ -333,6 +338,13 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) dev->tx_queue_len = *((u32 *) RTA_DATA(ida[IFLA_TXQLEN - 1])); } + if (ida[IFLA_WEIGHT - 1]) { + if (ida[IFLA_WEIGHT - 1]->rta_len != RTA_LENGTH(sizeof(u32))) + goto out; + + dev->weight = *((u32 *) RTA_DATA(ida[IFLA_WEIGHT - 1])); + } + err = 0; out: -- 2.53.0