bpf: rename bpf_compute_data_end into bpf_compute_data_pointers
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 25 Sep 2017 00:25:50 +0000 (02:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Sep 2017 20:36:44 +0000 (13:36 -0700)
Just do the rename into bpf_compute_data_pointers() as we'll add
one more pointer here to recompute.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/filter.h
kernel/bpf/sockmap.c
net/bpf/test_run.c
net/core/filter.c
net/core/lwt_bpf.c
net/sched/act_bpf.c
net/sched/cls_bpf.c

index d29e58fde364f01168c059f85faac389622a3fc3..052bab3d62e72294b6f85022c162be4c195894ae 100644 (file)
@@ -496,10 +496,13 @@ struct xdp_buff {
        void *data_hard_start;
 };
 
-/* compute the linear packet data range [data, data_end) which
- * will be accessed by cls_bpf, act_bpf and lwt programs
+/* Compute the linear packet data range [data, data_end) which
+ * will be accessed by various program types (cls_bpf, act_bpf,
+ * lwt, ...). Subsystems allowing direct data access must (!)
+ * ensure that cb[] area can be written to when BPF program is
+ * invoked (otherwise cb[] save/restore is necessary).
  */
-static inline void bpf_compute_data_end(struct sk_buff *skb)
+static inline void bpf_compute_data_pointers(struct sk_buff *skb)
 {
        struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb;
 
index 6424ce0e49698abee1da6242a0a8494d8ba0f03f..a298d66666981e51831427fea6ab83b7606f78c7 100644 (file)
@@ -102,7 +102,7 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb)
 
        skb_orphan(skb);
        skb->sk = psock->sock;
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        rc = (*prog->bpf_func)(skb, prog->insnsi);
        skb->sk = NULL;
 
@@ -369,7 +369,7 @@ static int smap_parse_func_strparser(struct strparser *strp,
         * any socket yet.
         */
        skb->sk = psock->sock;
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        rc = (*prog->bpf_func)(skb, prog->insnsi);
        skb->sk = NULL;
        rcu_read_unlock();
index 6be41a44d688a44970981fc9c2f1aa35666807fa..df672517b4fdbe58776469dacd70bf28c00440ea 100644 (file)
@@ -133,7 +133,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
        if (is_l2)
                __skb_push(skb, ETH_HLEN);
        if (is_direct_pkt_access)
-               bpf_compute_data_end(skb);
+               bpf_compute_data_pointers(skb);
        retval = bpf_test_run(prog, skb, repeat, &duration);
        if (!is_l2)
                __skb_push(skb, ETH_HLEN);
index 82edad58d066857aeee562661098effa3b3e6961..c468e7cfad195c39db88d71d9f9c8dd9a6c531ef 100644 (file)
@@ -1402,7 +1402,7 @@ static inline int bpf_try_make_writable(struct sk_buff *skb,
 {
        int err = __bpf_try_make_writable(skb, write_len);
 
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return err;
 }
 
@@ -1962,7 +1962,7 @@ BPF_CALL_3(bpf_skb_vlan_push, struct sk_buff *, skb, __be16, vlan_proto,
        ret = skb_vlan_push(skb, vlan_proto, vlan_tci);
        bpf_pull_mac_rcsum(skb);
 
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return ret;
 }
 
@@ -1984,7 +1984,7 @@ BPF_CALL_1(bpf_skb_vlan_pop, struct sk_buff *, skb)
        ret = skb_vlan_pop(skb);
        bpf_pull_mac_rcsum(skb);
 
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return ret;
 }
 
@@ -2178,7 +2178,7 @@ BPF_CALL_3(bpf_skb_change_proto, struct sk_buff *, skb, __be16, proto,
         * need to be verified first.
         */
        ret = bpf_skb_proto_xlat(skb, proto);
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return ret;
 }
 
@@ -2303,7 +2303,7 @@ static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff)
        ret = shrink ? bpf_skb_net_shrink(skb, len_diff_abs) :
                       bpf_skb_net_grow(skb, len_diff_abs);
 
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return ret;
 }
 
@@ -2394,7 +2394,7 @@ BPF_CALL_3(bpf_skb_change_tail, struct sk_buff *, skb, u32, new_len,
                        skb_gso_reset(skb);
        }
 
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return ret;
 }
 
@@ -2434,7 +2434,7 @@ BPF_CALL_3(bpf_skb_change_head, struct sk_buff *, skb, u32, head_room,
                skb_reset_mac_header(skb);
        }
 
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        return 0;
 }
 
index 1307731ddfe4aa8889d63eab13d0145ca3432f31..e7e626fb87bb34f89014cb16e58aaaf132c65417 100644 (file)
@@ -51,7 +51,7 @@ static int run_lwt_bpf(struct sk_buff *skb, struct bpf_lwt_prog *lwt,
         */
        preempt_disable();
        rcu_read_lock();
-       bpf_compute_data_end(skb);
+       bpf_compute_data_pointers(skb);
        ret = bpf_prog_run_save_cb(lwt->prog, skb);
        rcu_read_unlock();
 
index c0c707eb2c962520fbc6da655c8b4151bf8a4462..5ef8ce8c83d4ed8f12ca256acfaaab18c35fcaa0 100644 (file)
@@ -49,11 +49,11 @@ static int tcf_bpf(struct sk_buff *skb, const struct tc_action *act,
        filter = rcu_dereference(prog->filter);
        if (at_ingress) {
                __skb_push(skb, skb->mac_len);
-               bpf_compute_data_end(skb);
+               bpf_compute_data_pointers(skb);
                filter_res = BPF_PROG_RUN(filter, skb);
                __skb_pull(skb, skb->mac_len);
        } else {
-               bpf_compute_data_end(skb);
+               bpf_compute_data_pointers(skb);
                filter_res = BPF_PROG_RUN(filter, skb);
        }
        rcu_read_unlock();
index 520c5027646aea5146f22d7898acfbc7dee3385a..36671b0fb125338d262f98ac8a5a6e92f762f78b 100644 (file)
@@ -99,11 +99,11 @@ static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
                } else if (at_ingress) {
                        /* It is safe to push/pull even if skb_shared() */
                        __skb_push(skb, skb->mac_len);
-                       bpf_compute_data_end(skb);
+                       bpf_compute_data_pointers(skb);
                        filter_res = BPF_PROG_RUN(prog->filter, skb);
                        __skb_pull(skb, skb->mac_len);
                } else {
-                       bpf_compute_data_end(skb);
+                       bpf_compute_data_pointers(skb);
                        filter_res = BPF_PROG_RUN(prog->filter, skb);
                }