]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
nl-link-set: Add --state option
authorJulien BERNARD <jbernard@toulouse.viveris.fr>
Tue, 8 Oct 2013 11:04:30 +0000 (13:04 +0200)
committerThomas Graf <tgraf@suug.ch>
Tue, 22 Oct 2013 12:20:41 +0000 (14:20 +0200)
I modified the nl-link-set.c file to be able to set the interface up or
down. I joined the patch.
With the new nl-link-set binary I can set the tap interface down.
I am working with Ubuntu 12.04 LTS 64bits and the libnl and libnl-route
packages built from libnl3-3.2.3 from ubuntu reprositories.

--
Julien BERNARD

Signed-off-by: Thomas Graf <tgraf@suug.ch>
src/nl-link-set.c

index 5ff1e9d31758a1644b41236c5c27d49617f16bb9..bbb60f9765f4cd72df86ad49140070f4f2da436e 100644 (file)
@@ -42,6 +42,7 @@ static void print_usage(void)
        "     --txqlen=NUM      TX queue length\n"
        "     --weight=NUM      weight\n"
        "     --ifalias=NAME    alias name (SNMP IfAlias)\n"
+       "     --state=up/down   set interface up/down\n"
        );
        exit(0);
 }
@@ -86,6 +87,7 @@ int main(int argc, char *argv[])
                        ARG_TXQLEN,
                        ARG_WEIGHT,
                        ARG_IFALIAS,
+                       ARG_STATE,
                };
                static struct option long_opts[] = {
                        { "quiet", 0, 0, 'q' },
@@ -98,6 +100,7 @@ int main(int argc, char *argv[])
                        { "txqlen", 1, 0, ARG_TXQLEN },
                        { "weight", 1, 0, ARG_WEIGHT },
                        { "ifalias", 1, 0, ARG_IFALIAS },
+                       { "state", 1, 0, ARG_STATE },
                        { 0, 0, 0, 0 }
                };
 
@@ -116,6 +119,12 @@ int main(int argc, char *argv[])
                case ARG_TXQLEN: nl_cli_link_parse_txqlen(change, optarg); break;
                case ARG_WEIGHT: nl_cli_link_parse_weight(change, optarg); break;
                case ARG_IFALIAS: nl_cli_link_parse_ifalias(change, optarg); break;
+               case ARG_STATE:
+                       if(!strcmp(optarg, "up"))
+                               rtnl_link_set_flags(change, IFF_UP);
+                       else if(!strcmp(optarg, "down"))
+                               rtnl_link_unset_flags(change, IFF_UP);
+                       break;
                }
        }