" vxlan_opts MASKED-OPTIONS |\n"
" erspan_opts MASKED-OPTIONS |\n"
" gtp_opts MASKED-OPTIONS |\n"
+ " pfcp_opts MASKED-OPTIONS |\n"
" ip_flags IP-FLAGS |\n"
" l2_miss L2_MISS |\n"
" enc_dst_port [ port_number ] |\n"
return 0;
}
+static int flower_parse_pfcp_opt(char *str, struct nlmsghdr *n)
+{
+ struct rtattr *nest;
+ char *token;
+ int i, err;
+
+ nest = addattr_nest(n, MAX_MSG,
+ TCA_FLOWER_KEY_ENC_OPTS_PFCP | NLA_F_NESTED);
+
+ i = 1;
+ token = strsep(&str, ":");
+ while (token) {
+ switch (i) {
+ case TCA_FLOWER_KEY_ENC_OPT_PFCP_TYPE:
+ {
+ __u8 opt_type;
+
+ if (!strlen(token))
+ break;
+ err = get_u8(&opt_type, token, 16);
+ if (err)
+ return err;
+
+ addattr8(n, MAX_MSG, i, opt_type);
+ break;
+ }
+ case TCA_FLOWER_KEY_ENC_OPT_PFCP_SEID:
+ {
+ __be64 opt_seid;;
+
+ if (!strlen(token))
+ break;
+ err = get_be64(&opt_seid, token, 16);
+ if (err)
+ return err;
+
+ addattr64(n, MAX_MSG, i, opt_seid);
+ break;
+ }
+ default:
+ fprintf(stderr, "Unknown \"pfcp_opts\" type\n");
+ return -1;
+ }
+
+ token = strsep(&str, ":");
+ i++;
+ }
+ addattr_nest_end(n, nest);
+
+ return 0;
+}
+
static int flower_parse_geneve_opts(char *str, struct nlmsghdr *n)
{
char *token;
return 0;
}
+static int flower_parse_enc_opts_pfcp(char *str, struct nlmsghdr *n)
+{
+ char key[XATTR_SIZE_MAX], mask[XATTR_SIZE_MAX];
+ struct rtattr *nest;
+ char *slash;
+ int err;
+
+
+ slash = strchr(str, '/');
+ if (slash) {
+ *slash++ = '\0';
+ if (strlen(slash) > XATTR_SIZE_MAX)
+ return -1;
+ strcpy(mask, slash);
+ } else {
+ strcpy(mask, "ff:ffffffffffffffff");
+ }
+
+ if (strlen(str) > XATTR_SIZE_MAX)
+ return -1;
+ strcpy(key, str);
+
+ nest = addattr_nest(n, MAX_MSG, TCA_FLOWER_KEY_ENC_OPTS | NLA_F_NESTED);
+ err = flower_parse_pfcp_opt(key, n);
+ if (err)
+ return err;
+ addattr_nest_end(n, nest);
+
+ nest = addattr_nest(n, MAX_MSG,
+ TCA_FLOWER_KEY_ENC_OPTS_MASK | NLA_F_NESTED);
+ err = flower_parse_pfcp_opt(mask, n);
+ if (err)
+ return err;
+ addattr_nest_end(n, nest);
+
+ return 0;
+}
+
static int flower_parse_mpls_lse(int *argc_p, char ***argv_p,
struct nlmsghdr *nlh)
{
fprintf(stderr, "Illegal \"gtp_opts\"\n");
return -1;
}
+ } else if (!strcmp(*argv, "pfcp_opts")) {
+ NEXT_ARG();
+ ret = flower_parse_enc_opts_pfcp(*argv, n);
+ if (ret < 0) {
+ fprintf(stderr, "Illegal \"pfcp_opts\"\n");
+ return -1;
+ }
} else if (matches(*argv, "action") == 0) {
NEXT_ARG();
ret = parse_action(&argc, &argv, TCA_FLOWER_ACT, n);
snprintf(strbuf, len, "%02x:%02x", pdu_type, qfi);
}
+static void flower_print_pfcp_opts(const char *name, struct rtattr *attr,
+ char *strbuf, int len)
+{
+ struct rtattr *tb[TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX + 1];
+ struct rtattr *i = RTA_DATA(attr);
+ int rem = RTA_PAYLOAD(attr);
+ __be64 seid;
+ __u8 type;
+
+ parse_rtattr(tb, TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX, i, rem);
+ type = rta_getattr_u8(tb[TCA_FLOWER_KEY_ENC_OPT_PFCP_TYPE]);
+ seid = rta_getattr_be64(tb[TCA_FLOWER_KEY_ENC_OPT_PFCP_SEID]);
+
+ open_json_array(PRINT_JSON, name);
+ open_json_object(NULL);
+ print_uint(PRINT_JSON, "type", NULL, type);
+ print_uint(PRINT_JSON, "seid", NULL, seid);
+ close_json_object();
+ close_json_array(PRINT_JSON, name);
+
+ snprintf(strbuf, len, "%02x:%llx", type, seid);
+}
+
static void __attribute__((format(printf, 2, 0)))
flower_print_enc_parts(const char *name, const char *namefrm,
struct rtattr *attr, char *key, char *mask)
flower_print_enc_parts(name, " gtp_opts %s", attr, key,
msk);
+ } else if (key_tb[TCA_FLOWER_KEY_ENC_OPTS_PFCP]) {
+ flower_print_pfcp_opts("pfcp_opt_key",
+ key_tb[TCA_FLOWER_KEY_ENC_OPTS_PFCP],
+ key, len);
+
+ if (msk_tb[TCA_FLOWER_KEY_ENC_OPTS_PFCP])
+ flower_print_pfcp_opts("pfcp_opt_mask",
+ msk_tb[TCA_FLOWER_KEY_ENC_OPTS_PFCP],
+ msk, len);
+
+ flower_print_enc_parts(name, " pfcp_opts %s", attr, key,
+ msk);
}
free(msk);