iplink: add ipvtap support

IPVLAN and IPVTAP are using the same functions and parameters. So we can
just add a new link_util with id ipvtap. Others are the same.

Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
Hangbin Liu 2018-09-19 11:03:29 +08:00 committed by David Ahern
parent 34212c73b7
commit 88272775e2
3 changed files with 24 additions and 12 deletions

View File

@ -120,8 +120,8 @@ void iplink_usage(void)
"TYPE := { vlan | veth | vcan | vxcan | dummy | ifb | macvlan | macvtap |\n" "TYPE := { vlan | veth | vcan | vxcan | dummy | ifb | macvlan | macvtap |\n"
" bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n" " bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan |\n"
" gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan |\n" " gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan |\n"
" vti | nlmon | team_slave | bond_slave | ipvlan | geneve |\n" " vti | nlmon | team_slave | bond_slave | bridge_slave |\n"
" bridge_slave | vrf | macsec | netdevsim | rmnet }\n"); " ipvlan | ipvtap | geneve | vrf | macsec | netdevsim | rmnet }\n");
} }
exit(-1); exit(-1);
} }

View File

@ -1,4 +1,4 @@
/* iplink_ipvlan.c IPVLAN device support /* iplink_ipvlan.c IPVLAN/IPVTAP device support
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -18,15 +18,15 @@
#include "utils.h" #include "utils.h"
#include "ip_common.h" #include "ip_common.h"
static void ipvlan_explain(FILE *f) static void print_explain(struct link_util *lu, FILE *f)
{ {
fprintf(f, fprintf(f,
"Usage: ... ipvlan [ mode MODE ] [ FLAGS ]\n" "Usage: ... %s [ mode MODE ] [ FLAGS ]\n"
"\n" "\n"
"MODE: l3 | l3s | l2\n" "MODE: l3 | l3s | l2\n"
"FLAGS: bridge | private | vepa\n" "FLAGS: bridge | private | vepa\n"
"(first values are the defaults if nothing is specified).\n" "(first values are the defaults if nothing is specified).\n",
); lu->id);
} }
static int ipvlan_parse_opt(struct link_util *lu, int argc, char **argv, static int ipvlan_parse_opt(struct link_util *lu, int argc, char **argv,
@ -61,12 +61,12 @@ static int ipvlan_parse_opt(struct link_util *lu, int argc, char **argv,
} else if (matches(*argv, "bridge") == 0 && !mflag_given) { } else if (matches(*argv, "bridge") == 0 && !mflag_given) {
mflag_given = true; mflag_given = true;
} else if (matches(*argv, "help") == 0) { } else if (matches(*argv, "help") == 0) {
ipvlan_explain(stderr); print_explain(lu, stderr);
return -1; return -1;
} else { } else {
fprintf(stderr, "ipvlan: unknown option \"%s\"?\n", fprintf(stderr, "%s: unknown option \"%s\"?\n",
*argv); lu->id, *argv);
ipvlan_explain(stderr); print_explain(lu, stderr);
return -1; return -1;
} }
argc--; argc--;
@ -113,7 +113,7 @@ static void ipvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
static void ipvlan_print_help(struct link_util *lu, int argc, char **argv, static void ipvlan_print_help(struct link_util *lu, int argc, char **argv,
FILE *f) FILE *f)
{ {
ipvlan_explain(f); print_explain(lu, f);
} }
struct link_util ipvlan_link_util = { struct link_util ipvlan_link_util = {
@ -123,3 +123,11 @@ struct link_util ipvlan_link_util = {
.print_opt = ipvlan_print_opt, .print_opt = ipvlan_print_opt,
.print_help = ipvlan_print_help, .print_help = ipvlan_print_help,
}; };
struct link_util ipvtap_link_util = {
.id = "ipvtap",
.maxattr = IFLA_IPVLAN_MAX,
.parse_opt = ipvlan_parse_opt,
.print_opt = ipvlan_print_opt,
.print_help = ipvlan_print_help,
};

View File

@ -215,6 +215,7 @@ ip-link \- network device configuration
.BR vti " |" .BR vti " |"
.BR nlmon " |" .BR nlmon " |"
.BR ipvlan " |" .BR ipvlan " |"
.BR ipvtap " |"
.BR lowpan " |" .BR lowpan " |"
.BR geneve " |" .BR geneve " |"
.BR vrf " |" .BR vrf " |"
@ -329,6 +330,9 @@ Link types:
.BR ipvlan .BR ipvlan
- Interface for L3 (IPv6/IPv4) based VLANs - Interface for L3 (IPv6/IPv4) based VLANs
.sp .sp
.BR ipvtap
- Interface for L3 (IPv6/IPv4) based VLANs and TAP
.sp
.BR lowpan .BR lowpan
- Interface for 6LoWPAN (IPv6) over IEEE 802.15.4 / Bluetooth - Interface for 6LoWPAN (IPv6) over IEEE 802.15.4 / Bluetooth
.sp .sp