* [PATCH net-next v7 2/4] netlink: changes for setting and clearing protodown via netlink.
@ 2015-07-14 20:43 anuradhak
2015-07-15 17:32 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: anuradhak @ 2015-07-14 20:43 UTC (permalink / raw)
To: davem, sfeldma; +Cc: netdev, roopa, gospo, wkok, anuradhak
From: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
---
include/uapi/linux/if_link.h | 1 +
net/core/rtnetlink.c | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 2c7e8e3..24d68b7 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -148,6 +148,7 @@ enum {
IFLA_PHYS_SWITCH_ID,
IFLA_LINK_NETNSID,
IFLA_PHYS_PORT_NAME,
+ IFLA_PROTO_DOWN,
__IFLA_MAX
};
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 01ced4a..4104e27 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -896,7 +896,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
+ rtnl_link_get_size(dev) /* IFLA_LINKINFO */
+ rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
+ nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */
- + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_SWITCH_ID */
+ + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */
+ + nla_total_size(1); /* IFLA_PROTO_DOWN */
+
}
static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
@@ -1082,7 +1084,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
(dev->ifalias &&
nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
nla_put_u32(skb, IFLA_CARRIER_CHANGES,
- atomic_read(&dev->carrier_changes)))
+ atomic_read(&dev->carrier_changes)) ||
+ nla_put_u8(skb, IFLA_PROTO_DOWN, dev->proto_down))
goto nla_put_failure;
if (1) {
@@ -1319,6 +1322,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
[IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */
[IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
[IFLA_LINK_NETNSID] = { .type = NLA_S32 },
+ [IFLA_PROTO_DOWN] = { .type = NLA_U8 },
};
static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
@@ -1853,6 +1857,14 @@ static int do_setlink(const struct sk_buff *skb,
}
err = 0;
+ if (tb[IFLA_PROTO_DOWN]) {
+ err = dev_change_proto_down(dev,
+ nla_get_u8(tb[IFLA_PROTO_DOWN]));
+ if (err)
+ goto errout;
+ status |= DO_SETLINK_NOTIFY;
+ }
+
errout:
if (status & DO_SETLINK_MODIFIED) {
if (status & DO_SETLINK_NOTIFY)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v7 2/4] netlink: changes for setting and clearing protodown via netlink.
2015-07-14 20:43 [PATCH net-next v7 2/4] netlink: changes for setting and clearing protodown via netlink anuradhak
@ 2015-07-15 17:32 ` Stephen Hemminger
2015-07-15 17:50 ` Anuradha Karuppiah
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2015-07-15 17:32 UTC (permalink / raw)
To: anuradhak; +Cc: davem, sfeldma, netdev, roopa, gospo, wkok
On Tue, 14 Jul 2015 13:43:20 -0700
anuradhak@cumulusnetworks.com wrote:
> From: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
>
> Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
> Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
> Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
> ---
> include/uapi/linux/if_link.h | 1 +
> net/core/rtnetlink.c | 16 ++++++++++++++--
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index 2c7e8e3..24d68b7 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -148,6 +148,7 @@ enum {
> IFLA_PHYS_SWITCH_ID,
> IFLA_LINK_NETNSID,
> IFLA_PHYS_PORT_NAME,
> + IFLA_PROTO_DOWN,
> __IFLA_MAX
> };
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 01ced4a..4104e27 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -896,7 +896,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
> + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
> + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
> + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */
> - + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_SWITCH_ID */
> + + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */
> + + nla_total_size(1); /* IFLA_PROTO_DOWN */
> +
> }
>
> static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
> @@ -1082,7 +1084,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
> (dev->ifalias &&
> nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
> nla_put_u32(skb, IFLA_CARRIER_CHANGES,
> - atomic_read(&dev->carrier_changes)))
> + atomic_read(&dev->carrier_changes)) ||
> + nla_put_u8(skb, IFLA_PROTO_DOWN, dev->proto_down))
> goto nla_put_failure;
>
> if (1) {
> @@ -1319,6 +1322,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
> [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */
> [IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
> [IFLA_LINK_NETNSID] = { .type = NLA_S32 },
> + [IFLA_PROTO_DOWN] = { .type = NLA_U8 },
> };
>
> static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
> @@ -1853,6 +1857,14 @@ static int do_setlink(const struct sk_buff *skb,
> }
> err = 0;
>
> + if (tb[IFLA_PROTO_DOWN]) {
> + err = dev_change_proto_down(dev,
> + nla_get_u8(tb[IFLA_PROTO_DOWN]));
> + if (err)
> + goto errout;
> + status |= DO_SETLINK_NOTIFY;
> + }
> +
> errout:
> if (status & DO_SETLINK_MODIFIED) {
> if (status & DO_SETLINK_NOTIFY)
Why is this it's own attribute rather than a flag?
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH net-next v7 2/4] netlink: changes for setting and clearing protodown via netlink.
2015-07-15 17:32 ` Stephen Hemminger
@ 2015-07-15 17:50 ` Anuradha Karuppiah
0 siblings, 0 replies; 3+ messages in thread
From: Anuradha Karuppiah @ 2015-07-15 17:50 UTC (permalink / raw)
To: Stephen Hemminger
Cc: davem, sfeldma, netdev, Roopa Prabhu, Andy Gospodarek, Wilson Kok
-----Original Message-----
From: Stephen Hemminger [mailto:stephen@networkplumber.org]
Sent: Wednesday, July 15, 2015 10:32 AM
To: anuradhak@cumulusnetworks.com
Cc: davem@davemloft.net; sfeldma@gmail.com; netdev@vger.kernel.org;
roopa@cumulusnetworks.com; gospo@cumulusnetworks.com;
wkok@cumulusnetworks.com
Subject: Re: [PATCH net-next v7 2/4] netlink: changes for setting and
clearing protodown via netlink.
On Tue, 14 Jul 2015 13:43:20 -0700
anuradhak@cumulusnetworks.com wrote:
> From: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
>
> Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
> Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
> Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
> ---
> include/uapi/linux/if_link.h | 1 +
> net/core/rtnetlink.c | 16 ++++++++++++++--
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/linux/if_link.h
> b/include/uapi/linux/if_link.h index 2c7e8e3..24d68b7 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -148,6 +148,7 @@ enum {
> IFLA_PHYS_SWITCH_ID,
> IFLA_LINK_NETNSID,
> IFLA_PHYS_PORT_NAME,
> + IFLA_PROTO_DOWN,
> __IFLA_MAX
> };
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index
> 01ced4a..4104e27 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -896,7 +896,9 @@ static noinline size_t if_nlmsg_size(const struct
net_device *dev,
> + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
> + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
> + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID
*/
> - + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /*
IFLA_PHYS_SWITCH_ID */
> + + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /*
IFLA_PHYS_SWITCH_ID */
> + + nla_total_size(1); /* IFLA_PROTO_DOWN */
> +
> }
>
> static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device
> *dev) @@ -1082,7 +1084,8 @@ static int rtnl_fill_ifinfo(struct sk_buff
*skb, struct net_device *dev,
> (dev->ifalias &&
> nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
> nla_put_u32(skb, IFLA_CARRIER_CHANGES,
> - atomic_read(&dev->carrier_changes)))
> + atomic_read(&dev->carrier_changes)) ||
> + nla_put_u8(skb, IFLA_PROTO_DOWN, dev->proto_down))
> goto nla_put_failure;
>
> if (1) {
> @@ -1319,6 +1322,7 @@ static const struct nla_policy
ifla_policy[IFLA_MAX+1] = {
> [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */
> [IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len =
MAX_PHYS_ITEM_ID_LEN },
> [IFLA_LINK_NETNSID] = { .type = NLA_S32 },
> + [IFLA_PROTO_DOWN] = { .type = NLA_U8 },
> };
>
> static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
> @@ -1853,6 +1857,14 @@ static int do_setlink(const struct sk_buff *skb,
> }
> err = 0;
>
> + if (tb[IFLA_PROTO_DOWN]) {
> + err = dev_change_proto_down(dev,
> +
nla_get_u8(tb[IFLA_PROTO_DOWN]));
> + if (err)
> + goto errout;
> + status |= DO_SETLINK_NOTIFY;
> + }
> +
> errout:
> if (status & DO_SETLINK_MODIFIED) {
> if (status & DO_SETLINK_NOTIFY)
Why is this it's own attribute rather than a flag?
Hi Stephen,
I put out a version with this as a separate flags field (with proto_down
as a single bit). But there was some concern that proto_down will be the
only flag in the field so Dave recommended changing it to a boolean
attribute.
Anuradha.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-15 17:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14 20:43 [PATCH net-next v7 2/4] netlink: changes for setting and clearing protodown via netlink anuradhak
2015-07-15 17:32 ` Stephen Hemminger
2015-07-15 17:50 ` Anuradha Karuppiah
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).