Skip to content

Commit 6aaae2b

Browse files
borkmanndavem330
authored andcommitted
bpf: rename bpf_compute_data_end into bpf_compute_data_pointers
Just do the rename into bpf_compute_data_pointers() as we'll add one more pointer here to recompute. Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Acked-by: John Fastabend <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3bd3b9e commit 6aaae2b

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

include/linux/filter.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,13 @@ struct xdp_buff {
496496
void *data_hard_start;
497497
};
498498

499-
/* compute the linear packet data range [data, data_end) which
500-
* will be accessed by cls_bpf, act_bpf and lwt programs
499+
/* Compute the linear packet data range [data, data_end) which
500+
* will be accessed by various program types (cls_bpf, act_bpf,
501+
* lwt, ...). Subsystems allowing direct data access must (!)
502+
* ensure that cb[] area can be written to when BPF program is
503+
* invoked (otherwise cb[] save/restore is necessary).
501504
*/
502-
static inline void bpf_compute_data_end(struct sk_buff *skb)
505+
static inline void bpf_compute_data_pointers(struct sk_buff *skb)
503506
{
504507
struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb;
505508

kernel/bpf/sockmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb)
102102

103103
skb_orphan(skb);
104104
skb->sk = psock->sock;
105-
bpf_compute_data_end(skb);
105+
bpf_compute_data_pointers(skb);
106106
rc = (*prog->bpf_func)(skb, prog->insnsi);
107107
skb->sk = NULL;
108108

@@ -369,7 +369,7 @@ static int smap_parse_func_strparser(struct strparser *strp,
369369
* any socket yet.
370370
*/
371371
skb->sk = psock->sock;
372-
bpf_compute_data_end(skb);
372+
bpf_compute_data_pointers(skb);
373373
rc = (*prog->bpf_func)(skb, prog->insnsi);
374374
skb->sk = NULL;
375375
rcu_read_unlock();

net/bpf/test_run.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
133133
if (is_l2)
134134
__skb_push(skb, ETH_HLEN);
135135
if (is_direct_pkt_access)
136-
bpf_compute_data_end(skb);
136+
bpf_compute_data_pointers(skb);
137137
retval = bpf_test_run(prog, skb, repeat, &duration);
138138
if (!is_l2)
139139
__skb_push(skb, ETH_HLEN);

net/core/filter.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ static inline int bpf_try_make_writable(struct sk_buff *skb,
14021402
{
14031403
int err = __bpf_try_make_writable(skb, write_len);
14041404

1405-
bpf_compute_data_end(skb);
1405+
bpf_compute_data_pointers(skb);
14061406
return err;
14071407
}
14081408

@@ -1962,7 +1962,7 @@ BPF_CALL_3(bpf_skb_vlan_push, struct sk_buff *, skb, __be16, vlan_proto,
19621962
ret = skb_vlan_push(skb, vlan_proto, vlan_tci);
19631963
bpf_pull_mac_rcsum(skb);
19641964

1965-
bpf_compute_data_end(skb);
1965+
bpf_compute_data_pointers(skb);
19661966
return ret;
19671967
}
19681968

@@ -1984,7 +1984,7 @@ BPF_CALL_1(bpf_skb_vlan_pop, struct sk_buff *, skb)
19841984
ret = skb_vlan_pop(skb);
19851985
bpf_pull_mac_rcsum(skb);
19861986

1987-
bpf_compute_data_end(skb);
1987+
bpf_compute_data_pointers(skb);
19881988
return ret;
19891989
}
19901990

@@ -2178,7 +2178,7 @@ BPF_CALL_3(bpf_skb_change_proto, struct sk_buff *, skb, __be16, proto,
21782178
* need to be verified first.
21792179
*/
21802180
ret = bpf_skb_proto_xlat(skb, proto);
2181-
bpf_compute_data_end(skb);
2181+
bpf_compute_data_pointers(skb);
21822182
return ret;
21832183
}
21842184

@@ -2303,7 +2303,7 @@ static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff)
23032303
ret = shrink ? bpf_skb_net_shrink(skb, len_diff_abs) :
23042304
bpf_skb_net_grow(skb, len_diff_abs);
23052305

2306-
bpf_compute_data_end(skb);
2306+
bpf_compute_data_pointers(skb);
23072307
return ret;
23082308
}
23092309

@@ -2394,7 +2394,7 @@ BPF_CALL_3(bpf_skb_change_tail, struct sk_buff *, skb, u32, new_len,
23942394
skb_gso_reset(skb);
23952395
}
23962396

2397-
bpf_compute_data_end(skb);
2397+
bpf_compute_data_pointers(skb);
23982398
return ret;
23992399
}
24002400

@@ -2434,7 +2434,7 @@ BPF_CALL_3(bpf_skb_change_head, struct sk_buff *, skb, u32, head_room,
24342434
skb_reset_mac_header(skb);
24352435
}
24362436

2437-
bpf_compute_data_end(skb);
2437+
bpf_compute_data_pointers(skb);
24382438
return 0;
24392439
}
24402440

net/core/lwt_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int run_lwt_bpf(struct sk_buff *skb, struct bpf_lwt_prog *lwt,
5151
*/
5252
preempt_disable();
5353
rcu_read_lock();
54-
bpf_compute_data_end(skb);
54+
bpf_compute_data_pointers(skb);
5555
ret = bpf_prog_run_save_cb(lwt->prog, skb);
5656
rcu_read_unlock();
5757

net/sched/act_bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ static int tcf_bpf(struct sk_buff *skb, const struct tc_action *act,
4949
filter = rcu_dereference(prog->filter);
5050
if (at_ingress) {
5151
__skb_push(skb, skb->mac_len);
52-
bpf_compute_data_end(skb);
52+
bpf_compute_data_pointers(skb);
5353
filter_res = BPF_PROG_RUN(filter, skb);
5454
__skb_pull(skb, skb->mac_len);
5555
} else {
56-
bpf_compute_data_end(skb);
56+
bpf_compute_data_pointers(skb);
5757
filter_res = BPF_PROG_RUN(filter, skb);
5858
}
5959
rcu_read_unlock();

net/sched/cls_bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
9999
} else if (at_ingress) {
100100
/* It is safe to push/pull even if skb_shared() */
101101
__skb_push(skb, skb->mac_len);
102-
bpf_compute_data_end(skb);
102+
bpf_compute_data_pointers(skb);
103103
filter_res = BPF_PROG_RUN(prog->filter, skb);
104104
__skb_pull(skb, skb->mac_len);
105105
} else {
106-
bpf_compute_data_end(skb);
106+
bpf_compute_data_pointers(skb);
107107
filter_res = BPF_PROG_RUN(prog->filter, skb);
108108
}
109109

0 commit comments

Comments
 (0)