mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-11-05 00:47:30 +00:00
ip/tunnel: Minor cleanups
Few minor changes to reduce diffs between ip and ipv6 tunnel code:
1) reduce intendation by one level when adding attributes in gre and
gre6; reorder addattr*() calls to simplify diff
2) reorder local variables definition; change their type (e.g. for
IFLA_LINK) to match ones returned by rta_getattr_*()
3) move "mode" parameter parsing in link_iptnl.c to the similar
position as in link_ip6tnl.c
4) handle "tc" as shortcut for "tclass"/"tos" in link_iptnl.c
5) add whitespace where required
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
8e7548462e
commit
5bd937957d
@ -81,23 +81,23 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
|
||||
struct rtattr *tb[IFLA_MAX + 1];
|
||||
struct rtattr *linkinfo[IFLA_INFO_MAX+1];
|
||||
struct rtattr *greinfo[IFLA_GRE_MAX + 1];
|
||||
int len;
|
||||
__u16 iflags = 0;
|
||||
__u16 oflags = 0;
|
||||
__be32 ikey = 0;
|
||||
__be32 okey = 0;
|
||||
unsigned int saddr = 0;
|
||||
unsigned int daddr = 0;
|
||||
unsigned int link = 0;
|
||||
__u8 pmtudisc = 1;
|
||||
__u8 ttl = 0;
|
||||
__u8 ignore_df = 0;
|
||||
__u8 tos = 0;
|
||||
int len;
|
||||
__u8 ttl = 0;
|
||||
__u32 link = 0;
|
||||
__u16 encaptype = 0;
|
||||
__u16 encapflags = 0;
|
||||
__u16 encapsport = 0;
|
||||
__u16 encapdport = 0;
|
||||
__u8 metadata = 0;
|
||||
__u8 ignore_df = 0;
|
||||
__u32 fwmark = 0;
|
||||
__u32 erspan_idx = 0;
|
||||
__u8 erspan_ver = 0;
|
||||
@ -152,31 +152,34 @@ get_failed:
|
||||
pmtudisc = rta_getattr_u8(
|
||||
greinfo[IFLA_GRE_PMTUDISC]);
|
||||
|
||||
if (greinfo[IFLA_GRE_TTL])
|
||||
ttl = rta_getattr_u8(greinfo[IFLA_GRE_TTL]);
|
||||
if (greinfo[IFLA_GRE_IGNORE_DF])
|
||||
ignore_df =
|
||||
!!rta_getattr_u8(greinfo[IFLA_GRE_IGNORE_DF]);
|
||||
|
||||
if (greinfo[IFLA_GRE_TOS])
|
||||
tos = rta_getattr_u8(greinfo[IFLA_GRE_TOS]);
|
||||
|
||||
if (greinfo[IFLA_GRE_TTL])
|
||||
ttl = rta_getattr_u8(greinfo[IFLA_GRE_TTL]);
|
||||
|
||||
if (greinfo[IFLA_GRE_LINK])
|
||||
link = rta_getattr_u32(greinfo[IFLA_GRE_LINK]);
|
||||
|
||||
if (greinfo[IFLA_GRE_ENCAP_TYPE])
|
||||
encaptype = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_TYPE]);
|
||||
|
||||
if (greinfo[IFLA_GRE_ENCAP_FLAGS])
|
||||
encapflags = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_FLAGS]);
|
||||
|
||||
if (greinfo[IFLA_GRE_ENCAP_SPORT])
|
||||
encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
|
||||
|
||||
if (greinfo[IFLA_GRE_ENCAP_DPORT])
|
||||
encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
|
||||
|
||||
if (greinfo[IFLA_GRE_COLLECT_METADATA])
|
||||
metadata = 1;
|
||||
|
||||
if (greinfo[IFLA_GRE_IGNORE_DF])
|
||||
ignore_df =
|
||||
!!rta_getattr_u8(greinfo[IFLA_GRE_IGNORE_DF]);
|
||||
|
||||
if (greinfo[IFLA_GRE_FWMARK])
|
||||
fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
|
||||
|
||||
@ -353,49 +356,47 @@ get_failed:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!metadata) {
|
||||
addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
|
||||
addattr32(n, 1024, IFLA_GRE_OKEY, okey);
|
||||
addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_LOCAL, &saddr, 4);
|
||||
addattr_l(n, 1024, IFLA_GRE_REMOTE, &daddr, 4);
|
||||
addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
|
||||
if (ignore_df)
|
||||
addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
|
||||
if (link)
|
||||
addattr32(n, 1024, IFLA_GRE_LINK, link);
|
||||
addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
|
||||
addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
|
||||
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
|
||||
if (erspan_ver) {
|
||||
addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
|
||||
if (erspan_ver == 1 && erspan_idx != 0) {
|
||||
addattr32(n, 1024,
|
||||
IFLA_GRE_ERSPAN_INDEX, erspan_idx);
|
||||
} else if (erspan_ver == 2) {
|
||||
addattr8(n, 1024,
|
||||
IFLA_GRE_ERSPAN_DIR, erspan_dir);
|
||||
addattr16(n, 1024,
|
||||
IFLA_GRE_ERSPAN_HWID, erspan_hwid);
|
||||
}
|
||||
}
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
|
||||
} else {
|
||||
if (metadata) {
|
||||
addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
|
||||
addattr32(n, 1024, IFLA_GRE_OKEY, okey);
|
||||
addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_LOCAL, &saddr, 4);
|
||||
addattr_l(n, 1024, IFLA_GRE_REMOTE, &daddr, 4);
|
||||
addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
|
||||
if (ignore_df)
|
||||
addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
|
||||
addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
|
||||
if (link)
|
||||
addattr32(n, 1024, IFLA_GRE_LINK, link);
|
||||
addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
|
||||
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
|
||||
if (erspan_ver) {
|
||||
addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
|
||||
if (erspan_ver == 1 && erspan_idx != 0) {
|
||||
addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
|
||||
} else if (erspan_ver == 2) {
|
||||
addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
|
||||
addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
|
||||
}
|
||||
}
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
{
|
||||
char s2[64];
|
||||
unsigned int iflags = 0;
|
||||
unsigned int oflags = 0;
|
||||
__u16 iflags = 0;
|
||||
__u16 oflags = 0;
|
||||
__u8 ttl = 0;
|
||||
__u8 tos = 0;
|
||||
|
||||
@ -411,7 +412,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
tnl_print_endpoint("local", tb[IFLA_GRE_LOCAL], AF_INET);
|
||||
|
||||
if (tb[IFLA_GRE_LINK]) {
|
||||
unsigned int link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
|
||||
__u32 link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
|
||||
|
||||
if (link) {
|
||||
print_string(PRINT_ANY, "link", "dev %s ",
|
||||
|
||||
@ -92,23 +92,23 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
|
||||
struct rtattr *tb[IFLA_MAX + 1];
|
||||
struct rtattr *linkinfo[IFLA_INFO_MAX+1];
|
||||
struct rtattr *greinfo[IFLA_GRE_MAX + 1];
|
||||
int len;
|
||||
__u16 iflags = 0;
|
||||
__u16 oflags = 0;
|
||||
__be32 ikey = 0;
|
||||
__be32 okey = 0;
|
||||
struct in6_addr raddr = IN6ADDR_ANY_INIT;
|
||||
struct in6_addr laddr = IN6ADDR_ANY_INIT;
|
||||
unsigned int link = 0;
|
||||
unsigned int flowinfo = 0;
|
||||
unsigned int flags = 0;
|
||||
__u8 hop_limit = DEFAULT_TNL_HOP_LIMIT;
|
||||
__u8 encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
|
||||
__u32 flowinfo = 0;
|
||||
__u32 flags = 0;
|
||||
__u32 link = 0;
|
||||
__u16 encaptype = 0;
|
||||
__u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
|
||||
__u16 encapsport = 0;
|
||||
__u16 encapdport = 0;
|
||||
__u8 metadata = 0;
|
||||
int len;
|
||||
__u32 fwmark = 0;
|
||||
__u32 erspan_idx = 0;
|
||||
__u8 erspan_ver = 0;
|
||||
@ -183,12 +183,12 @@ get_failed:
|
||||
if (greinfo[IFLA_GRE_ENCAP_SPORT])
|
||||
encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
|
||||
|
||||
if (greinfo[IFLA_GRE_COLLECT_METADATA])
|
||||
metadata = 1;
|
||||
|
||||
if (greinfo[IFLA_GRE_ENCAP_DPORT])
|
||||
encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
|
||||
|
||||
if (greinfo[IFLA_GRE_COLLECT_METADATA])
|
||||
metadata = 1;
|
||||
|
||||
if (greinfo[IFLA_GRE_FWMARK])
|
||||
fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
|
||||
|
||||
@ -389,49 +389,47 @@ get_failed:
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
if (!metadata) {
|
||||
addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
|
||||
addattr32(n, 1024, IFLA_GRE_OKEY, okey);
|
||||
addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
|
||||
addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
|
||||
if (link)
|
||||
addattr32(n, 1024, IFLA_GRE_LINK, link);
|
||||
addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
|
||||
addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
|
||||
addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
|
||||
addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
|
||||
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
|
||||
if (erspan_ver) {
|
||||
addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
|
||||
if (erspan_ver == 1 && erspan_idx != 0) {
|
||||
addattr32(n, 1024,
|
||||
IFLA_GRE_ERSPAN_INDEX, erspan_idx);
|
||||
} else if (erspan_ver == 2) {
|
||||
addattr8(n, 1024,
|
||||
IFLA_GRE_ERSPAN_DIR, erspan_dir);
|
||||
addattr16(n, 1024,
|
||||
IFLA_GRE_ERSPAN_HWID, erspan_hwid);
|
||||
}
|
||||
}
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
|
||||
} else {
|
||||
if (metadata) {
|
||||
addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
|
||||
addattr32(n, 1024, IFLA_GRE_OKEY, okey);
|
||||
addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
|
||||
addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
|
||||
addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
|
||||
if (link)
|
||||
addattr32(n, 1024, IFLA_GRE_LINK, link);
|
||||
addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
|
||||
addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
|
||||
addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
|
||||
addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
|
||||
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
|
||||
if (erspan_ver) {
|
||||
addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
|
||||
if (erspan_ver == 1 && erspan_idx != 0) {
|
||||
addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
|
||||
} else if (erspan_ver == 2) {
|
||||
addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
|
||||
addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
|
||||
}
|
||||
}
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
|
||||
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
{
|
||||
char s2[64];
|
||||
unsigned int iflags = 0;
|
||||
unsigned int oflags = 0;
|
||||
unsigned int flags = 0;
|
||||
__u16 iflags = 0;
|
||||
__u16 oflags = 0;
|
||||
__u32 flags = 0;
|
||||
__u32 flowinfo = 0;
|
||||
__u8 ttl = 0;
|
||||
|
||||
@ -453,7 +451,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
tnl_print_endpoint("local", tb[IFLA_GRE_LOCAL], AF_INET6);
|
||||
|
||||
if (tb[IFLA_GRE_LINK]) {
|
||||
unsigned int link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
|
||||
__u32 link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
|
||||
|
||||
if (link) {
|
||||
print_string(PRINT_ANY, "link", "dev %s ",
|
||||
@ -550,6 +548,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
|
||||
if (tb[IFLA_GRE_ERSPAN_INDEX]) {
|
||||
__u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
|
||||
|
||||
print_uint(PRINT_ANY,
|
||||
"erspan_index", "erspan_index %u ", erspan_idx);
|
||||
}
|
||||
|
||||
@ -99,8 +99,8 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
|
||||
__u8 encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
|
||||
__u32 flowinfo = 0;
|
||||
__u32 flags = 0;
|
||||
__u32 link = 0;
|
||||
__u8 proto = 0;
|
||||
__u32 link = 0;
|
||||
__u16 encaptype = 0;
|
||||
__u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
|
||||
__u16 encapsport = 0;
|
||||
@ -169,7 +169,7 @@ get_failed:
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
if (matches(*argv, "mode") == 0) {
|
||||
if (strcmp(*argv, "mode") == 0) {
|
||||
NEXT_ARG();
|
||||
if (strcmp(*argv, "ipv6/ipv6") == 0 ||
|
||||
strcmp(*argv, "ip6ip6") == 0)
|
||||
@ -222,9 +222,9 @@ get_failed:
|
||||
encap_limit = uval;
|
||||
flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
|
||||
}
|
||||
} else if (strcmp(*argv, "tclass") == 0 ||
|
||||
} else if (strcmp(*argv, "tos") == 0 ||
|
||||
strcmp(*argv, "tclass") == 0 ||
|
||||
strcmp(*argv, "tc") == 0 ||
|
||||
strcmp(*argv, "tos") == 0 ||
|
||||
matches(*argv, "dsfield") == 0) {
|
||||
__u8 uval;
|
||||
|
||||
@ -321,6 +321,7 @@ get_failed:
|
||||
addattr_l(n, 1024, IFLA_IPTUN_COLLECT_METADATA, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
addattr_l(n, 1024, IFLA_IPTUN_LOCAL, &laddr, sizeof(laddr));
|
||||
addattr_l(n, 1024, IFLA_IPTUN_REMOTE, &raddr, sizeof(raddr));
|
||||
addattr8(n, 1024, IFLA_IPTUN_TTL, hop_limit);
|
||||
@ -341,7 +342,7 @@ get_failed:
|
||||
static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
{
|
||||
char s2[64];
|
||||
int flags = 0;
|
||||
__u32 flags = 0;
|
||||
__u32 flowinfo = 0;
|
||||
__u8 ttl = 0;
|
||||
|
||||
@ -377,7 +378,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
|
||||
tnl_print_endpoint("local", tb[IFLA_IPTUN_LOCAL], AF_INET6);
|
||||
|
||||
if (tb[IFLA_IPTUN_LINK]) {
|
||||
unsigned int link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
|
||||
__u32 link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
|
||||
|
||||
if (link) {
|
||||
print_string(PRINT_ANY, "link", "dev %s ",
|
||||
|
||||
@ -90,18 +90,18 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
|
||||
struct rtattr *linkinfo[IFLA_INFO_MAX+1];
|
||||
struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
|
||||
int len;
|
||||
__u32 link = 0;
|
||||
__u32 laddr = 0;
|
||||
__u32 raddr = 0;
|
||||
__u8 ttl = 0;
|
||||
__u8 tos = 0;
|
||||
__u8 pmtudisc = 1;
|
||||
__u8 tos = 0;
|
||||
__u16 iflags = 0;
|
||||
__u8 proto = 0;
|
||||
__u8 ttl = 0;
|
||||
struct in6_addr ip6rdprefix = {};
|
||||
__u16 ip6rdprefixlen = 0;
|
||||
__u32 ip6rdrelayprefix = 0;
|
||||
__u16 ip6rdrelayprefixlen = 0;
|
||||
__u8 proto = 0;
|
||||
__u32 link = 0;
|
||||
__u16 encaptype = 0;
|
||||
__u16 encapflags = 0;
|
||||
__u16 encapsport = 0;
|
||||
@ -144,13 +144,13 @@ get_failed:
|
||||
if (iptuninfo[IFLA_IPTUN_TTL])
|
||||
ttl = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TTL]);
|
||||
|
||||
if (iptuninfo[IFLA_IPTUN_TOS])
|
||||
tos = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TOS]);
|
||||
|
||||
if (iptuninfo[IFLA_IPTUN_PMTUDISC])
|
||||
pmtudisc =
|
||||
rta_getattr_u8(iptuninfo[IFLA_IPTUN_PMTUDISC]);
|
||||
|
||||
if (iptuninfo[IFLA_IPTUN_TOS])
|
||||
tos = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TOS]);
|
||||
|
||||
if (iptuninfo[IFLA_IPTUN_FLAGS])
|
||||
iflags = rta_getattr_u16(iptuninfo[IFLA_IPTUN_FLAGS]);
|
||||
|
||||
@ -194,7 +194,25 @@ get_failed:
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
if (strcmp(*argv, "remote") == 0) {
|
||||
if (strcmp(*argv, "mode") == 0) {
|
||||
NEXT_ARG();
|
||||
if (strcmp(lu->id, "sit") == 0 &&
|
||||
(strcmp(*argv, "ipv6/ipv4") == 0 ||
|
||||
strcmp(*argv, "ip6ip") == 0))
|
||||
proto = IPPROTO_IPV6;
|
||||
else if (strcmp(*argv, "ipv4/ipv4") == 0 ||
|
||||
strcmp(*argv, "ipip") == 0 ||
|
||||
strcmp(*argv, "ip4ip4") == 0)
|
||||
proto = IPPROTO_IPIP;
|
||||
else if (strcmp(*argv, "mpls/ipv4") == 0 ||
|
||||
strcmp(*argv, "mplsip") == 0)
|
||||
proto = IPPROTO_MPLS;
|
||||
else if (strcmp(*argv, "any/ipv4") == 0 ||
|
||||
strcmp(*argv, "any") == 0)
|
||||
proto = 0;
|
||||
else
|
||||
invarg("Cannot guess tunnel mode.", *argv);
|
||||
} else if (strcmp(*argv, "remote") == 0) {
|
||||
NEXT_ARG();
|
||||
raddr = get_addr32(*argv);
|
||||
} else if (strcmp(*argv, "local") == 0) {
|
||||
@ -216,6 +234,7 @@ get_failed:
|
||||
ttl = 0;
|
||||
} else if (strcmp(*argv, "tos") == 0 ||
|
||||
strcmp(*argv, "tclass") == 0 ||
|
||||
strcmp(*argv, "tc") == 0 ||
|
||||
matches(*argv, "dsfield") == 0) {
|
||||
__u32 uval;
|
||||
|
||||
@ -233,24 +252,6 @@ get_failed:
|
||||
} else if (strcmp(lu->id, "sit") == 0 &&
|
||||
strcmp(*argv, "isatap") == 0) {
|
||||
iflags |= SIT_ISATAP;
|
||||
} else if (strcmp(*argv, "mode") == 0) {
|
||||
NEXT_ARG();
|
||||
if (strcmp(lu->id, "sit") == 0 &&
|
||||
(strcmp(*argv, "ipv6/ipv4") == 0 ||
|
||||
strcmp(*argv, "ip6ip") == 0))
|
||||
proto = IPPROTO_IPV6;
|
||||
else if (strcmp(*argv, "ipv4/ipv4") == 0 ||
|
||||
strcmp(*argv, "ipip") == 0 ||
|
||||
strcmp(*argv, "ip4ip4") == 0)
|
||||
proto = IPPROTO_IPIP;
|
||||
else if (strcmp(*argv, "mpls/ipv4") == 0 ||
|
||||
strcmp(*argv, "mplsip") == 0)
|
||||
proto = IPPROTO_MPLS;
|
||||
else if (strcmp(*argv, "any/ipv4") == 0 ||
|
||||
strcmp(*argv, "any") == 0)
|
||||
proto = 0;
|
||||
else
|
||||
invarg("Cannot guess tunnel mode.", *argv);
|
||||
} else if (strcmp(*argv, "noencap") == 0) {
|
||||
encaptype = TUNNEL_ENCAP_NONE;
|
||||
} else if (strcmp(*argv, "encap") == 0) {
|
||||
@ -333,12 +334,12 @@ get_failed:
|
||||
return 0;
|
||||
}
|
||||
|
||||
addattr32(n, 1024, IFLA_IPTUN_LINK, link);
|
||||
addattr32(n, 1024, IFLA_IPTUN_LOCAL, laddr);
|
||||
addattr32(n, 1024, IFLA_IPTUN_REMOTE, raddr);
|
||||
addattr8(n, 1024, IFLA_IPTUN_TTL, ttl);
|
||||
addattr8(n, 1024, IFLA_IPTUN_TOS, tos);
|
||||
addattr8(n, 1024, IFLA_IPTUN_PMTUDISC, pmtudisc);
|
||||
addattr8(n, 1024, IFLA_IPTUN_TOS, tos);
|
||||
addattr8(n, 1024, IFLA_IPTUN_TTL, ttl);
|
||||
addattr32(n, 1024, IFLA_IPTUN_LINK, link);
|
||||
addattr32(n, 1024, IFLA_IPTUN_FWMARK, fwmark);
|
||||
|
||||
addattr16(n, 1024, IFLA_IPTUN_ENCAP_TYPE, encaptype);
|
||||
@ -399,7 +400,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
|
||||
tnl_print_endpoint("local", tb[IFLA_IPTUN_LOCAL], AF_INET);
|
||||
|
||||
if (tb[IFLA_IPTUN_LINK]) {
|
||||
unsigned int link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
|
||||
__u32 link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
|
||||
|
||||
if (link) {
|
||||
print_string(PRINT_ANY, "link", "dev %s ",
|
||||
|
||||
@ -174,7 +174,7 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
tnl_print_endpoint("local", tb[IFLA_VTI_LOCAL], AF_INET);
|
||||
|
||||
if (tb[IFLA_VTI_LINK]) {
|
||||
unsigned int link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
|
||||
__u32 link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
|
||||
|
||||
if (link) {
|
||||
print_string(PRINT_ANY, "link", "dev %s ",
|
||||
|
||||
@ -182,7 +182,7 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||
tnl_print_endpoint("local", tb[IFLA_VTI_LOCAL], AF_INET6);
|
||||
|
||||
if (tb[IFLA_VTI_LINK]) {
|
||||
unsigned int link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
|
||||
__u32 link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
|
||||
|
||||
if (link) {
|
||||
print_string(PRINT_ANY, "link", "dev %s ",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user