lwtunnel: Pass encap and encap_type attributes to lwt_parse_encap
lwt_parse_encap currently assumes the encap attribute is RTA_ENCAP and the type is RTA_ENCAP_TYPE. Change lwt_parse_encap to take these as input arguments for reuse by nexthop code which has the attributes as NHA_ENCAP and NHA_ENCAP_TYPE. Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
2360b8cb21
commit
7392401027
|
|
@ -134,7 +134,8 @@ int bond_parse_xstats(struct link_util *lu, int argc, char **argv);
|
||||||
int bond_print_xstats(struct nlmsghdr *n, void *arg);
|
int bond_print_xstats(struct nlmsghdr *n, void *arg);
|
||||||
|
|
||||||
/* iproute_lwtunnel.c */
|
/* iproute_lwtunnel.c */
|
||||||
int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp);
|
int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp,
|
||||||
|
int encap_attr, int encap_type_attr);
|
||||||
void lwt_print_encap(FILE *fp, struct rtattr *encap_type, struct rtattr *encap);
|
void lwt_print_encap(FILE *fp, struct rtattr *encap_type, struct rtattr *encap);
|
||||||
|
|
||||||
/* iplink_xdp.c */
|
/* iplink_xdp.c */
|
||||||
|
|
|
||||||
|
|
@ -997,7 +997,8 @@ static int parse_one_nh(struct nlmsghdr *n, struct rtmsg *r,
|
||||||
} else if (strcmp(*argv, "encap") == 0) {
|
} else if (strcmp(*argv, "encap") == 0) {
|
||||||
int old_len = rta->rta_len;
|
int old_len = rta->rta_len;
|
||||||
|
|
||||||
if (lwt_parse_encap(rta, len, &argc, &argv))
|
if (lwt_parse_encap(rta, len, &argc, &argv,
|
||||||
|
RTA_ENCAP, RTA_ENCAP_TYPE))
|
||||||
return -1;
|
return -1;
|
||||||
rtnh->rtnh_len += rta->rta_len - old_len;
|
rtnh->rtnh_len += rta->rta_len - old_len;
|
||||||
} else if (strcmp(*argv, "as") == 0) {
|
} else if (strcmp(*argv, "as") == 0) {
|
||||||
|
|
@ -1416,7 +1417,8 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
|
||||||
rta->rta_type = RTA_ENCAP;
|
rta->rta_type = RTA_ENCAP;
|
||||||
rta->rta_len = RTA_LENGTH(0);
|
rta->rta_len = RTA_LENGTH(0);
|
||||||
|
|
||||||
lwt_parse_encap(rta, sizeof(buf), &argc, &argv);
|
lwt_parse_encap(rta, sizeof(buf), &argc, &argv,
|
||||||
|
RTA_ENCAP, RTA_ENCAP_TYPE);
|
||||||
|
|
||||||
if (rta->rta_len > RTA_LENGTH(0))
|
if (rta->rta_len > RTA_LENGTH(0))
|
||||||
addraw_l(&req.n, 1024
|
addraw_l(&req.n, 1024
|
||||||
|
|
|
||||||
|
|
@ -1111,7 +1111,8 @@ static int parse_encap_bpf(struct rtattr *rta, size_t len, int *argcp,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp)
|
int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp,
|
||||||
|
int encap_attr, int encap_type_attr)
|
||||||
{
|
{
|
||||||
struct rtattr *nest;
|
struct rtattr *nest;
|
||||||
int argc = *argcp;
|
int argc = *argcp;
|
||||||
|
|
@ -1131,7 +1132,7 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp)
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
nest = rta_nest(rta, len, RTA_ENCAP);
|
nest = rta_nest(rta, len, encap_attr);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LWTUNNEL_ENCAP_MPLS:
|
case LWTUNNEL_ENCAP_MPLS:
|
||||||
ret = parse_encap_mpls(rta, len, &argc, &argv);
|
ret = parse_encap_mpls(rta, len, &argc, &argv);
|
||||||
|
|
@ -1164,7 +1165,7 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp)
|
||||||
|
|
||||||
rta_nest_end(rta, nest);
|
rta_nest_end(rta, nest);
|
||||||
|
|
||||||
ret = rta_addattr16(rta, len, RTA_ENCAP_TYPE, type);
|
ret = rta_addattr16(rta, len, encap_type_attr, type);
|
||||||
|
|
||||||
*argcp = argc;
|
*argcp = argc;
|
||||||
*argvp = argv;
|
*argvp = argv;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue