aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2014-07-30 23:34:16 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-02 18:03:58 -0400
commit7ae457c1e5b45a1b826fad9d62b32191d2bdcfdb (patch)
treedcb1aba57530e6c9426a81758173ca146ffafcaf /drivers/isdn/i4l
parent8fb575ca396bc31d9fa99c26336e2432b41d1bfc (diff)
net: filter: split 'struct sk_filter' into socket and bpf parts
clean up names related to socket filtering and bpf in the following way: - everything that deals with sockets keeps 'sk_*' prefix - everything that is pure BPF is changed to 'bpf_*' prefix split 'struct sk_filter' into struct sk_filter { atomic_t refcnt; struct rcu_head rcu; struct bpf_prog *prog; }; and struct bpf_prog { u32 jited:1, len:31; struct sock_fprog_kern *orig_prog; unsigned int (*bpf_func)(const struct sk_buff *skb, const struct bpf_insn *filter); union { struct sock_filter insns[0]; struct bpf_insn insnsi[0]; struct work_struct work; }; }; so that 'struct bpf_prog' can be used independent of sockets and cleans up 'unattached' bpf use cases split SK_RUN_FILTER macro into: SK_RUN_FILTER to be used with 'struct sk_filter *' and BPF_PROG_RUN to be used with 'struct bpf_prog *' __sk_filter_release(struct sk_filter *) gains __bpf_prog_release(struct bpf_prog *) helper function also perform related renames for the functions that work with 'struct bpf_prog *', since they're on the same lines: sk_filter_size -> bpf_prog_size sk_filter_select_runtime -> bpf_prog_select_runtime sk_filter_free -> bpf_prog_free sk_unattached_filter_create -> bpf_prog_create sk_unattached_filter_destroy -> bpf_prog_destroy sk_store_orig_filter -> bpf_prog_store_orig_filter sk_release_orig_filter -> bpf_release_orig_filter __sk_migrate_filter -> bpf_migrate_filter __sk_prepare_filter -> bpf_prepare_filter API for attaching classic BPF to a socket stays the same: sk_attach_filter(prog, struct sock *)/sk_detach_filter(struct sock *) and SK_RUN_FILTER(struct sk_filter *, ctx) to execute a program which is used by sockets, tun, af_packet API for 'unattached' BPF programs becomes: bpf_prog_create(struct bpf_prog **)/bpf_prog_destroy(struct bpf_prog *) and BPF_PROG_RUN(struct bpf_prog *, ctx) to execute a program which is used by isdn, ppp, team, seccomp, ptp, xt_bpf, cls_bpf, test_bpf Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 62f0688d45a5..c4198fa490bf 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -379,12 +379,12 @@ isdn_ppp_release(int min, struct file *file)
379#endif 379#endif
380#ifdef CONFIG_IPPP_FILTER 380#ifdef CONFIG_IPPP_FILTER
381 if (is->pass_filter) { 381 if (is->pass_filter) {
382 sk_unattached_filter_destroy(is->pass_filter); 382 bpf_prog_destroy(is->pass_filter);
383 is->pass_filter = NULL; 383 is->pass_filter = NULL;
384 } 384 }
385 385
386 if (is->active_filter) { 386 if (is->active_filter) {
387 sk_unattached_filter_destroy(is->active_filter); 387 bpf_prog_destroy(is->active_filter);
388 is->active_filter = NULL; 388 is->active_filter = NULL;
389 } 389 }
390#endif 390#endif
@@ -639,12 +639,11 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
639 fprog.filter = code; 639 fprog.filter = code;
640 640
641 if (is->pass_filter) { 641 if (is->pass_filter) {
642 sk_unattached_filter_destroy(is->pass_filter); 642 bpf_prog_destroy(is->pass_filter);
643 is->pass_filter = NULL; 643 is->pass_filter = NULL;
644 } 644 }
645 if (fprog.filter != NULL) 645 if (fprog.filter != NULL)
646 err = sk_unattached_filter_create(&is->pass_filter, 646 err = bpf_prog_create(&is->pass_filter, &fprog);
647 &fprog);
648 else 647 else
649 err = 0; 648 err = 0;
650 kfree(code); 649 kfree(code);
@@ -664,12 +663,11 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
664 fprog.filter = code; 663 fprog.filter = code;
665 664
666 if (is->active_filter) { 665 if (is->active_filter) {
667 sk_unattached_filter_destroy(is->active_filter); 666 bpf_prog_destroy(is->active_filter);
668 is->active_filter = NULL; 667 is->active_filter = NULL;
669 } 668 }
670 if (fprog.filter != NULL) 669 if (fprog.filter != NULL)
671 err = sk_unattached_filter_create(&is->active_filter, 670 err = bpf_prog_create(&is->active_filter, &fprog);
672 &fprog);
673 else 671 else
674 err = 0; 672 err = 0;
675 kfree(code); 673 kfree(code);
@@ -1174,14 +1172,14 @@ isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *
1174 } 1172 }
1175 1173
1176 if (is->pass_filter 1174 if (is->pass_filter
1177 && SK_RUN_FILTER(is->pass_filter, skb) == 0) { 1175 && BPF_PROG_RUN(is->pass_filter, skb) == 0) {
1178 if (is->debug & 0x2) 1176 if (is->debug & 0x2)
1179 printk(KERN_DEBUG "IPPP: inbound frame filtered.\n"); 1177 printk(KERN_DEBUG "IPPP: inbound frame filtered.\n");
1180 kfree_skb(skb); 1178 kfree_skb(skb);
1181 return; 1179 return;
1182 } 1180 }
1183 if (!(is->active_filter 1181 if (!(is->active_filter
1184 && SK_RUN_FILTER(is->active_filter, skb) == 0)) { 1182 && BPF_PROG_RUN(is->active_filter, skb) == 0)) {
1185 if (is->debug & 0x2) 1183 if (is->debug & 0x2)
1186 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); 1184 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n");
1187 lp->huptimer = 0; 1185 lp->huptimer = 0;
@@ -1320,14 +1318,14 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1320 } 1318 }
1321 1319
1322 if (ipt->pass_filter 1320 if (ipt->pass_filter
1323 && SK_RUN_FILTER(ipt->pass_filter, skb) == 0) { 1321 && BPF_PROG_RUN(ipt->pass_filter, skb) == 0) {
1324 if (ipt->debug & 0x4) 1322 if (ipt->debug & 0x4)
1325 printk(KERN_DEBUG "IPPP: outbound frame filtered.\n"); 1323 printk(KERN_DEBUG "IPPP: outbound frame filtered.\n");
1326 kfree_skb(skb); 1324 kfree_skb(skb);
1327 goto unlock; 1325 goto unlock;
1328 } 1326 }
1329 if (!(ipt->active_filter 1327 if (!(ipt->active_filter
1330 && SK_RUN_FILTER(ipt->active_filter, skb) == 0)) { 1328 && BPF_PROG_RUN(ipt->active_filter, skb) == 0)) {
1331 if (ipt->debug & 0x4) 1329 if (ipt->debug & 0x4)
1332 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); 1330 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n");
1333 lp->huptimer = 0; 1331 lp->huptimer = 0;
@@ -1517,9 +1515,9 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
1517 } 1515 }
1518 1516
1519 drop |= is->pass_filter 1517 drop |= is->pass_filter
1520 && SK_RUN_FILTER(is->pass_filter, skb) == 0; 1518 && BPF_PROG_RUN(is->pass_filter, skb) == 0;
1521 drop |= is->active_filter 1519 drop |= is->active_filter
1522 && SK_RUN_FILTER(is->active_filter, skb) == 0; 1520 && BPF_PROG_RUN(is->active_filter, skb) == 0;
1523 1521
1524 skb_push(skb, IPPP_MAX_HEADER - 4); 1522 skb_push(skb, IPPP_MAX_HEADER - 4);
1525 return drop; 1523 return drop;