On 8/26/20 3:19 PM, Hangbin Liu wrote:
[...]
+BPF_CALL_3(bpf_xdp_redirect_map_multi, struct bpf_map *, map,
+          struct bpf_map *, ex_map, u64, flags)
+{
+       struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
+
+       /* Limit ex_map type to DEVMAP_HASH to get better performance */
+       if (unlikely(!map ||

Why is test on !map needed when arg1_type is ARG_CONST_MAP_PTR? Verifier must
guarantee that it's a valid map ptr .. are you saying this is not the case for
this helper?

+                    (ex_map && ex_map->map_type != BPF_MAP_TYPE_DEVMAP_HASH) ||
+                    flags & ~BPF_F_EXCLUDE_INGRESS))
+               return XDP_ABORTED;
+
+       ri->tgt_index = 0;
+       /* Set the tgt_value to NULL to distinguish with bpf_xdp_redirect_map */
+       ri->tgt_value = NULL;
+       ri->flags = flags;
+       ri->ex_map = ex_map;
+
+       WRITE_ONCE(ri->map, map);
+
+       return XDP_REDIRECT;
+}
+
+static const struct bpf_func_proto bpf_xdp_redirect_map_multi_proto = {
+       .func           = bpf_xdp_redirect_map_multi,
+       .gpl_only       = false,
+       .ret_type       = RET_INTEGER,
+       .arg1_type      = ARG_CONST_MAP_PTR,
+       .arg2_type      = ARG_CONST_MAP_PTR_OR_NULL,
+       .arg3_type      = ARG_ANYTHING,
+};
+
  static unsigned long bpf_skb_copy(void *dst_buff, const void *skb,
                                  unsigned long off, unsigned long len)
  {
@@ -6833,6 +6933,8 @@ xdp_func_proto(enum bpf_func_id func_id, const struct 
bpf_prog *prog)
                return &bpf_xdp_redirect_proto;
        case BPF_FUNC_redirect_map:
                return &bpf_xdp_redirect_map_proto;
+       case BPF_FUNC_redirect_map_multi:
+               return &bpf_xdp_redirect_map_multi_proto;
        case BPF_FUNC_xdp_adjust_tail:
                return &bpf_xdp_adjust_tail_proto;
        case BPF_FUNC_fib_lookup:

Reply via email to