All of lore.kernel.org
 help / color / mirror / Atom feed
* [iproute2] iplink: add support for IFLA_CARRIER attribute
@ 2017-04-26  7:08 Zhang Shengju
  2017-04-26  9:59 ` Nikolay Aleksandrov
  2017-04-26 15:07 ` Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang Shengju @ 2017-04-26  7:08 UTC (permalink / raw)
  To: netdev

Add support to set IFLA_CARRIER attribute.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
 ip/iplink.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ip/iplink.c b/ip/iplink.c
index 866ad72..263bfdd 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -72,6 +72,7 @@ void iplink_usage(void)
 		"	                  [ allmulticast { on | off } ]\n"
 		"	                  [ promisc { on | off } ]\n"
 		"	                  [ trailers { on | off } ]\n"
+		"	                  [ carrier { on | off } ]\n"
 		"	                  [ txqueuelen PACKETS ]\n"
 		"	                  [ name NEWNAME ]\n"
 		"	                  [ address LLADDR ]\n"
@@ -673,6 +674,17 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 				req->i.ifi_flags |= IFF_NOARP;
 			else
 				return on_off("arp", *argv);
+		} else if (strcmp(*argv, "carrier") == 0) {
+			int carrier;
+			NEXT_ARG();
+			if (strcmp(*argv, "on") == 0)
+				carrier = 1;
+			else if (strcmp(*argv, "off") == 0)
+				carrier = 0;
+			else
+				return on_off("carrier", *argv);
+
+			addattr8(&req->n, sizeof(*req), IFLA_CARRIER, carrier);
 		} else if (strcmp(*argv, "vf") == 0) {
 			struct rtattr *vflist;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [iproute2] iplink: add support for IFLA_CARRIER attribute
  2017-04-26  7:08 [iproute2] iplink: add support for IFLA_CARRIER attribute Zhang Shengju
@ 2017-04-26  9:59 ` Nikolay Aleksandrov
  2017-04-26 15:07 ` Stephen Hemminger
  1 sibling, 0 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2017-04-26  9:59 UTC (permalink / raw)
  To: Zhang Shengju, netdev

On 26/04/17 10:08, Zhang Shengju wrote:
> Add support to set IFLA_CARRIER attribute.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
>  ip/iplink.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 

You should also update the ip-link man page with this new option.

> diff --git a/ip/iplink.c b/ip/iplink.c
> index 866ad72..263bfdd 100644
> --- a/ip/iplink.c
> +++ b/ip/iplink.c
> @@ -72,6 +72,7 @@ void iplink_usage(void)
>  		"	                  [ allmulticast { on | off } ]\n"
>  		"	                  [ promisc { on | off } ]\n"
>  		"	                  [ trailers { on | off } ]\n"
> +		"	                  [ carrier { on | off } ]\n"
>  		"	                  [ txqueuelen PACKETS ]\n"
>  		"	                  [ name NEWNAME ]\n"
>  		"	                  [ address LLADDR ]\n"
> @@ -673,6 +674,17 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
>  				req->i.ifi_flags |= IFF_NOARP;
>  			else
>  				return on_off("arp", *argv);
> +		} else if (strcmp(*argv, "carrier") == 0) {
> +			int carrier;

Please leave a blank line between the variable definition and the code.

> +			NEXT_ARG();
> +			if (strcmp(*argv, "on") == 0)
> +				carrier = 1;
> +			else if (strcmp(*argv, "off") == 0)
> +				carrier = 0;
> +			else
> +				return on_off("carrier", *argv);
> +
> +			addattr8(&req->n, sizeof(*req), IFLA_CARRIER, carrier);
>  		} else if (strcmp(*argv, "vf") == 0) {
>  			struct rtattr *vflist;
>  
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [iproute2] iplink: add support for IFLA_CARRIER attribute
  2017-04-26  7:08 [iproute2] iplink: add support for IFLA_CARRIER attribute Zhang Shengju
  2017-04-26  9:59 ` Nikolay Aleksandrov
@ 2017-04-26 15:07 ` Stephen Hemminger
  2017-04-27  6:35   ` 张胜举
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2017-04-26 15:07 UTC (permalink / raw)
  To: Zhang Shengju; +Cc: netdev

On Wed, 26 Apr 2017 15:08:39 +0800
Zhang Shengju <zhangshengju@cmss.chinamobile.com> wrote:

> Add support to set IFLA_CARRIER attribute.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
>  ip/iplink.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/ip/iplink.c b/ip/iplink.c
> index 866ad72..263bfdd 100644
> --- a/ip/iplink.c
> +++ b/ip/iplink.c
> @@ -72,6 +72,7 @@ void iplink_usage(void)
>  		"	                  [ allmulticast { on | off } ]\n"
>  		"	                  [ promisc { on | off } ]\n"
>  		"	                  [ trailers { on | off } ]\n"
> +		"	                  [ carrier { on | off } ]\n"
>  		"	                  [ txqueuelen PACKETS ]\n"
>  		"	                  [ name NEWNAME ]\n"
>  		"	                  [ address LLADDR ]\n"
> @@ -673,6 +674,17 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
>  				req->i.ifi_flags |= IFF_NOARP;
>  			else
>  				return on_off("arp", *argv);
> +		} else if (strcmp(*argv, "carrier") == 0) {
> +			int carrier;
> +			NEXT_ARG();
> +			if (strcmp(*argv, "on") == 0)
> +				carrier = 1;
> +			else if (strcmp(*argv, "off") == 0)
> +				carrier = 0;
> +			else
> +				return on_off("carrier", *argv);
> +
> +			addattr8(&req->n, sizeof(*req), IFLA_CARRIER, carrier);
>  		} else if (strcmp(*argv, "vf") == 0) {
>  			struct rtattr *vflist;
>  

The general policy of ip link command is all options should be invertable.
There are some VPN's that use this to save and restore state. So if you add
an option to set something there should be similar output under the detailed show command.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [iproute2] iplink: add support for IFLA_CARRIER attribute
  2017-04-26 15:07 ` Stephen Hemminger
@ 2017-04-27  6:35   ` 张胜举
  2017-05-01 16:16     ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: 张胜举 @ 2017-04-27  6:35 UTC (permalink / raw)
  To: 'Stephen Hemminger'; +Cc: netdev

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, April 26, 2017 11:08 PM
> To: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Cc: netdev@vger.kernel.org
> Subject: Re: [iproute2] iplink: add support for IFLA_CARRIER attribute
> 
> On Wed, 26 Apr 2017 15:08:39 +0800
> Zhang Shengju <zhangshengju@cmss.chinamobile.com> wrote:
> 
> > Add support to set IFLA_CARRIER attribute.
> >
> > Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> > ---
> >  ip/iplink.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/ip/iplink.c b/ip/iplink.c index 866ad72..263bfdd 100644
> > --- a/ip/iplink.c
> > +++ b/ip/iplink.c
> > @@ -72,6 +72,7 @@ void iplink_usage(void)
> >  		"	                  [ allmulticast { on | off } ]\n"
> >  		"	                  [ promisc { on | off } ]\n"
> >  		"	                  [ trailers { on | off } ]\n"
> > +		"	                  [ carrier { on | off } ]\n"
> >  		"	                  [ txqueuelen PACKETS ]\n"
> >  		"	                  [ name NEWNAME ]\n"
> >  		"	                  [ address LLADDR ]\n"
> > @@ -673,6 +674,17 @@ int iplink_parse(int argc, char **argv, struct
> iplink_req *req,
> >  				req->i.ifi_flags |= IFF_NOARP;
> >  			else
> >  				return on_off("arp", *argv);
> > +		} else if (strcmp(*argv, "carrier") == 0) {
> > +			int carrier;
> > +			NEXT_ARG();
> > +			if (strcmp(*argv, "on") == 0)
> > +				carrier = 1;
> > +			else if (strcmp(*argv, "off") == 0)
> > +				carrier = 0;
> > +			else
> > +				return on_off("carrier", *argv);
> > +
> > +			addattr8(&req->n, sizeof(*req), IFLA_CARRIER,
> carrier);
> >  		} else if (strcmp(*argv, "vf") == 0) {
> >  			struct rtattr *vflist;
> >
> 
> The general policy of ip link command is all options should be invertable.
Yes, so I add 'on' and 'off' subcommand to make sure that it can be
invertable.

> There are some VPN's that use this to save and restore state. So if you
add
> an option to set something there should be similar output under the
detailed
> show command.
Currently, "show command" already can display 'carrier' status. Such as:
 dummy0: <NO-CARRIER...>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [iproute2] iplink: add support for IFLA_CARRIER attribute
  2017-04-27  6:35   ` 张胜举
@ 2017-05-01 16:16     ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-05-01 16:16 UTC (permalink / raw)
  To: 张胜举; +Cc: netdev

On Thu, 27 Apr 2017 14:35:01 +0800
张胜举 <zhangshengju@cmss.chinamobile.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Wednesday, April 26, 2017 11:08 PM
> > To: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> > Cc: netdev@vger.kernel.org
> > Subject: Re: [iproute2] iplink: add support for IFLA_CARRIER attribute
> > 
> > On Wed, 26 Apr 2017 15:08:39 +0800
> > Zhang Shengju <zhangshengju@cmss.chinamobile.com> wrote:
> >   
> > > Add support to set IFLA_CARRIER attribute.
> > >
> > > Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> > > ---
> > >  ip/iplink.c | 12 ++++++++++++
> > >  1 file changed, 12 insertions(+)
> > >
> > > diff --git a/ip/iplink.c b/ip/iplink.c index 866ad72..263bfdd 100644
> > > --- a/ip/iplink.c
> > > +++ b/ip/iplink.c
> > > @@ -72,6 +72,7 @@ void iplink_usage(void)
> > >  		"	                  [ allmulticast { on | off } ]\n"
> > >  		"	                  [ promisc { on | off } ]\n"
> > >  		"	                  [ trailers { on | off } ]\n"
> > > +		"	                  [ carrier { on | off } ]\n"
> > >  		"	                  [ txqueuelen PACKETS ]\n"
> > >  		"	                  [ name NEWNAME ]\n"
> > >  		"	                  [ address LLADDR ]\n"
> > > @@ -673,6 +674,17 @@ int iplink_parse(int argc, char **argv, struct  
> > iplink_req *req,  
> > >  				req->i.ifi_flags |= IFF_NOARP;
> > >  			else
> > >  				return on_off("arp", *argv);
> > > +		} else if (strcmp(*argv, "carrier") == 0) {
> > > +			int carrier;
> > > +			NEXT_ARG();
> > > +			if (strcmp(*argv, "on") == 0)
> > > +				carrier = 1;
> > > +			else if (strcmp(*argv, "off") == 0)
> > > +				carrier = 0;
> > > +			else
> > > +				return on_off("carrier", *argv);
> > > +
> > > +			addattr8(&req->n, sizeof(*req), IFLA_CARRIER,  
> > carrier);  
> > >  		} else if (strcmp(*argv, "vf") == 0) {
> > >  			struct rtattr *vflist;
> > >  
> > 
> > The general policy of ip link command is all options should be invertable.  
> Yes, so I add 'on' and 'off' subcommand to make sure that it can be
> invertable.
> 
> > There are some VPN's that use this to save and restore state. So if you  
> add
> > an option to set something there should be similar output under the  
> detailed
> > show command.  
> Currently, "show command" already can display 'carrier' status. Such as:
>  dummy0: <NO-CARRIER...>
> 

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-01 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  7:08 [iproute2] iplink: add support for IFLA_CARRIER attribute Zhang Shengju
2017-04-26  9:59 ` Nikolay Aleksandrov
2017-04-26 15:07 ` Stephen Hemminger
2017-04-27  6:35   ` 张胜举
2017-05-01 16:16     ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.