diff options
author | Julien BERNARD <jbernard@toulouse.viveris.fr> | 2013-10-08 11:04:30 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-10-22 12:20:41 (GMT) |
commit | 27019c5671b146fd42de352c7722d398c5740ec6 (patch) | |
tree | bcf78f20c2b9aefab475f9fe9204205c614a4f78 /src | |
parent | 20ab3bfa78ebc41a6a2c2cbe00320695158687b8 (diff) | |
download | libnl-27019c5671b146fd42de352c7722d398c5740ec6.zip libnl-27019c5671b146fd42de352c7722d398c5740ec6.tar.gz libnl-27019c5671b146fd42de352c7722d398c5740ec6.tar.bz2 |
nl-link-set: Add --state option
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/nl-link-set.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nl-link-set.c b/src/nl-link-set.c index 5ff1e9d..bbb60f9 100644 --- a/src/nl-link-set.c +++ b/src/nl-link-set.c @@ -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; } } |