Lines Matching refs:slwt

42 	int (*build_state)(struct seg6_local_lwt *slwt, const void *cfg,
44 void (*destroy_state)(struct seg6_local_lwt *slwt);
65 int (*input)(struct sk_buff *skb, struct seg6_local_lwt *slwt);
379 struct seg6_local_lwt *slwt)
387 struct seg6_local_lwt *slwt)
397 return input_action_end_finish(skb, slwt);
404 static int end_next_csid_core(struct sk_buff *skb, struct seg6_local_lwt *slwt)
406 const struct seg6_flavors_info *finfo = &slwt->flv_info;
410 return input_action_end_core(skb, slwt);
415 return input_action_end_finish(skb, slwt);
419 struct seg6_local_lwt *slwt)
421 seg6_lookup_nexthop(skb, &slwt->nh6, 0);
427 struct seg6_local_lwt *slwt)
437 return input_action_end_x_finish(skb, slwt);
445 struct seg6_local_lwt *slwt)
447 const struct seg6_flavors_info *finfo = &slwt->flv_info;
451 return input_action_end_x_core(skb, slwt);
456 return input_action_end_x_finish(skb, slwt);
739 static int end_flv8986_core(struct sk_buff *skb, struct seg6_local_lwt *slwt)
741 const struct seg6_flavors_info *finfo = &slwt->flv_info;
785 return input_action_end_finish(skb, slwt);
793 static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt)
795 const struct seg6_flavors_info *finfo = &slwt->flv_info;
799 return input_action_end_core(skb, slwt);
803 return end_next_csid_core(skb, slwt);
810 return end_flv8986_core(skb, slwt);
814 static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
816 const struct seg6_flavors_info *finfo = &slwt->flv_info;
821 return end_x_next_csid_core(skb, slwt);
823 return input_action_end_x_core(skb, slwt);
826 static int input_action_end_t(struct sk_buff *skb, struct seg6_local_lwt *slwt)
836 seg6_lookup_nexthop(skb, NULL, slwt->table);
847 struct seg6_local_lwt *slwt)
869 odev = dev_get_by_index_rcu(net, slwt->oif);
907 struct seg6_local_lwt *slwt;
909 slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
914 * If slwt->nh6 is set to ::, then lookup the nexthop for the
917 if (!ipv6_addr_any(&slwt->nh6))
918 nhaddr = &slwt->nh6;
927 struct seg6_local_lwt *slwt)
957 struct seg6_local_lwt *slwt;
962 slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
966 nhaddr = slwt->nh4.s_addr ?: iph->daddr;
980 struct seg6_local_lwt *slwt)
1011 static int __seg6_end_dt_vrf_build(struct seg6_local_lwt *slwt, const void *cfg,
1014 struct seg6_end_dt_info *info = &slwt->dt_info;
1129 struct seg6_local_lwt *slwt, u16 family)
1131 struct seg6_end_dt_info *info = &slwt->dt_info;
1175 struct seg6_local_lwt *slwt)
1186 skb = end_dt_vrf_core(skb, slwt, AF_INET);
1207 static int seg6_end_dt4_build(struct seg6_local_lwt *slwt, const void *cfg,
1210 return __seg6_end_dt_vrf_build(slwt, cfg, AF_INET, extack);
1214 seg6_end_dt_mode seg6_end_dt6_parse_mode(struct seg6_local_lwt *slwt)
1216 unsigned long parsed_optattrs = slwt->parsed_optattrs;
1229 static enum seg6_end_dt_mode seg6_end_dt6_get_mode(struct seg6_local_lwt *slwt)
1231 struct seg6_end_dt_info *info = &slwt->dt_info;
1236 static int seg6_end_dt6_build(struct seg6_local_lwt *slwt, const void *cfg,
1239 enum seg6_end_dt_mode mode = seg6_end_dt6_parse_mode(slwt);
1240 struct seg6_end_dt_info *info = &slwt->dt_info;
1247 return __seg6_end_dt_vrf_build(slwt, cfg, AF_INET6, extack);
1256 struct seg6_local_lwt *slwt)
1265 if (seg6_end_dt6_get_mode(slwt) == DT_LEGACY_MODE)
1269 skb = end_dt_vrf_core(skb, slwt, AF_INET6);
1288 seg6_lookup_any_nexthop(skb, NULL, slwt->table, true);
1298 static int seg6_end_dt46_build(struct seg6_local_lwt *slwt, const void *cfg,
1301 return __seg6_end_dt_vrf_build(slwt, cfg, AF_UNSPEC, extack);
1305 struct seg6_local_lwt *slwt)
1316 return input_action_end_dt4(skb, slwt);
1318 return input_action_end_dt6(skb, slwt);
1328 static int input_action_end_b6(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1337 err = seg6_do_srh_inline(skb, slwt->srh);
1354 struct seg6_local_lwt *slwt)
1368 err = seg6_do_srh_encap(skb, slwt->srh, IPPROTO_IPV6);
1409 struct seg6_local_lwt *slwt)
1433 ret = bpf_prog_run_save_cb(slwt->bpf.prog, skb);
1576 static bool seg6_lwtunnel_counters_enabled(struct seg6_local_lwt *slwt)
1578 return slwt->parsed_optattrs & SEG6_F_LOCAL_COUNTERS;
1581 static void seg6_local_update_counters(struct seg6_local_lwt *slwt,
1586 pcounters = this_cpu_ptr(slwt->pcpu_counters);
1604 struct seg6_local_lwt *slwt;
1608 slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
1609 desc = slwt->desc;
1611 rc = desc->input(skb, slwt);
1613 if (!seg6_lwtunnel_counters_enabled(slwt))
1616 seg6_local_update_counters(slwt, len, rc);
1652 static int parse_nla_srh(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1668 slwt->srh = kmemdup(srh, len, GFP_KERNEL);
1669 if (!slwt->srh)
1672 slwt->headroom += len;
1677 static int put_nla_srh(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1683 srh = slwt->srh;
1705 static void destroy_attr_srh(struct seg6_local_lwt *slwt)
1707 kfree(slwt->srh);
1710 static int parse_nla_table(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1713 slwt->table = nla_get_u32(attrs[SEG6_LOCAL_TABLE]);
1718 static int put_nla_table(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1720 if (nla_put_u32(skb, SEG6_LOCAL_TABLE, slwt->table))
1735 seg6_end_dt_info *seg6_possible_end_dt_info(struct seg6_local_lwt *slwt)
1738 return &slwt->dt_info;
1745 struct seg6_local_lwt *slwt,
1748 struct seg6_end_dt_info *info = seg6_possible_end_dt_info(slwt);
1758 static int put_nla_vrftable(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1760 struct seg6_end_dt_info *info = seg6_possible_end_dt_info(slwt);
1782 static int parse_nla_nh4(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1785 memcpy(&slwt->nh4, nla_data(attrs[SEG6_LOCAL_NH4]),
1791 static int put_nla_nh4(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1799 memcpy(nla_data(nla), &slwt->nh4, sizeof(struct in_addr));
1809 static int parse_nla_nh6(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1812 memcpy(&slwt->nh6, nla_data(attrs[SEG6_LOCAL_NH6]),
1818 static int put_nla_nh6(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1826 memcpy(nla_data(nla), &slwt->nh6, sizeof(struct in6_addr));
1836 static int parse_nla_iif(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1839 slwt->iif = nla_get_u32(attrs[SEG6_LOCAL_IIF]);
1844 static int put_nla_iif(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1846 if (nla_put_u32(skb, SEG6_LOCAL_IIF, slwt->iif))
1860 static int parse_nla_oif(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1863 slwt->oif = nla_get_u32(attrs[SEG6_LOCAL_OIF]);
1868 static int put_nla_oif(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1870 if (nla_put_u32(skb, SEG6_LOCAL_OIF, slwt->oif))
1891 static int parse_nla_bpf(struct nlattr **attrs, struct seg6_local_lwt *slwt,
1908 slwt->bpf.name = nla_memdup(tb[SEG6_LOCAL_BPF_PROG_NAME], GFP_KERNEL);
1909 if (!slwt->bpf.name)
1915 kfree(slwt->bpf.name);
1919 slwt->bpf.prog = p;
1923 static int put_nla_bpf(struct sk_buff *skb, struct seg6_local_lwt *slwt)
1927 if (!slwt->bpf.prog)
1934 if (nla_put_u32(skb, SEG6_LOCAL_BPF_PROG, slwt->bpf.prog->aux->id))
1937 if (slwt->bpf.name &&
1938 nla_put_string(skb, SEG6_LOCAL_BPF_PROG_NAME, slwt->bpf.name))
1955 static void destroy_attr_bpf(struct seg6_local_lwt *slwt)
1957 kfree(slwt->bpf.name);
1958 if (slwt->bpf.prog)
1959 bpf_prog_put(slwt->bpf.prog);
1970 struct seg6_local_lwt *slwt,
1995 slwt->pcpu_counters = pcounters;
2018 static int put_nla_counters(struct sk_buff *skb, struct seg6_local_lwt *slwt)
2033 pcounters = per_cpu_ptr(slwt->pcpu_counters, i);
2064 static void destroy_attr_counters(struct seg6_local_lwt *slwt)
2066 free_percpu(slwt->pcpu_counters);
2129 static int parse_nla_flavors(struct nlattr **attrs, struct seg6_local_lwt *slwt,
2132 struct seg6_flavors_info *finfo = &slwt->flv_info;
2134 int action = slwt->action;
2185 static int put_nla_flavors(struct sk_buff *skb, struct seg6_local_lwt *slwt)
2187 struct seg6_flavors_info *finfo = &slwt->flv_info;
2242 static int encap_size_flavors(struct seg6_local_lwt *slwt)
2244 struct seg6_flavors_info *finfo = &slwt->flv_info;
2258 int (*parse)(struct nlattr **attrs, struct seg6_local_lwt *slwt,
2260 int (*put)(struct sk_buff *skb, struct seg6_local_lwt *slwt);
2267 void (*destroy)(struct seg6_local_lwt *slwt);
2320 struct seg6_local_lwt *slwt)
2341 param->destroy(slwt);
2348 static void destroy_attrs(struct seg6_local_lwt *slwt)
2350 unsigned long attrs = slwt->desc->attrs | slwt->parsed_optattrs;
2352 __destroy_attrs(attrs, SEG6_LOCAL_MAX + 1, slwt);
2356 struct seg6_local_lwt *slwt,
2359 struct seg6_action_desc *desc = slwt->desc;
2373 err = param->parse(attrs, slwt, extack);
2384 slwt->parsed_optattrs = parsed_optattrs;
2389 __destroy_attrs(parsed_optattrs, i, slwt);
2398 seg6_local_lwtunnel_build_state(struct seg6_local_lwt *slwt, const void *cfg,
2401 struct seg6_action_desc *desc = slwt->desc;
2408 return ops->build_state(slwt, cfg, extack);
2414 static void seg6_local_lwtunnel_destroy_state(struct seg6_local_lwt *slwt)
2416 struct seg6_action_desc *desc = slwt->desc;
2423 ops->destroy_state(slwt);
2426 static int parse_nla_action(struct nlattr **attrs, struct seg6_local_lwt *slwt,
2434 desc = __get_action_desc(slwt->action);
2441 slwt->desc = desc;
2442 slwt->headroom += desc->static_headroom;
2471 err = param->parse(attrs, slwt, extack);
2478 err = parse_nla_optional_attrs(attrs, slwt, extack);
2488 __destroy_attrs(desc->attrs, i, slwt);
2500 struct seg6_local_lwt *slwt;
2515 newts = lwtunnel_state_alloc(sizeof(*slwt));
2519 slwt = seg6_local_lwtunnel(newts);
2520 slwt->action = nla_get_u32(tb[SEG6_LOCAL_ACTION]);
2522 err = parse_nla_action(tb, slwt, extack);
2526 err = seg6_local_lwtunnel_build_state(slwt, cfg, extack);
2532 newts->headroom = slwt->headroom;
2539 destroy_attrs(slwt);
2547 struct seg6_local_lwt *slwt = seg6_local_lwtunnel(lwt);
2549 seg6_local_lwtunnel_destroy_state(slwt);
2551 destroy_attrs(slwt);
2559 struct seg6_local_lwt *slwt = seg6_local_lwtunnel(lwt);
2564 if (nla_put_u32(skb, SEG6_LOCAL_ACTION, slwt->action))
2567 attrs = slwt->desc->attrs | slwt->parsed_optattrs;
2572 err = param->put(skb, slwt);
2583 struct seg6_local_lwt *slwt = seg6_local_lwtunnel(lwt);
2589 attrs = slwt->desc->attrs | slwt->parsed_optattrs;
2592 nlsize += nla_total_size((slwt->srh->hdrlen + 1) << 3);
2627 nlsize += encap_size_flavors(slwt);