aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-03-28 13:58:24 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-31 00:45:09 -0400
commit77e0114ae9ae08685c503772a57af21d299c6701 (patch)
tree204dbaf897612e96900e82123300db5c6cfcf85a /drivers/isdn/i4l
parent568f194e8bd16c353ad50f9ab95d98b20578a39d (diff)
net: isdn: use sk_unattached_filter api
Similarly as in ppp, we need to migrate the ISDN/PPP code to make use of the sk_unattached_filter api in order to decouple having direct filter structure access. By using sk_unattached_filter_{create,destroy}, we can allow for the possibility to jit compile filters for faster filter verdicts as well. Joint work with Alexei Starovoitov. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Cc: Karsten Keil <isdn@linux-pingi.de> Cc: isdn4linux@listserv.isdn4linux.de Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c61
1 files changed, 41 insertions, 20 deletions
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 38ceac5053a0..a5da511e3c9a 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -378,10 +378,15 @@ isdn_ppp_release(int min, struct file *file)
378 is->slcomp = NULL; 378 is->slcomp = NULL;
379#endif 379#endif
380#ifdef CONFIG_IPPP_FILTER 380#ifdef CONFIG_IPPP_FILTER
381 kfree(is->pass_filter); 381 if (is->pass_filter) {
382 is->pass_filter = NULL; 382 sk_unattached_filter_destroy(is->pass_filter);
383 kfree(is->active_filter); 383 is->pass_filter = NULL;
384 is->active_filter = NULL; 384 }
385
386 if (is->active_filter) {
387 sk_unattached_filter_destroy(is->active_filter);
388 is->active_filter = NULL;
389 }
385#endif 390#endif
386 391
387/* TODO: if this was the previous master: link the stuff to the new master */ 392/* TODO: if this was the previous master: link the stuff to the new master */
@@ -629,25 +634,41 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
629#ifdef CONFIG_IPPP_FILTER 634#ifdef CONFIG_IPPP_FILTER
630 case PPPIOCSPASS: 635 case PPPIOCSPASS:
631 { 636 {
637 struct sock_fprog fprog;
632 struct sock_filter *code; 638 struct sock_filter *code;
633 int len = get_filter(argp, &code); 639 int err, len = get_filter(argp, &code);
640
634 if (len < 0) 641 if (len < 0)
635 return len; 642 return len;
636 kfree(is->pass_filter); 643
637 is->pass_filter = code; 644 fprog.len = len;
638 is->pass_len = len; 645 fprog.filter = code;
639 break; 646
647 if (is->pass_filter)
648 sk_unattached_filter_destroy(is->pass_filter);
649 err = sk_unattached_filter_create(&is->pass_filter, &fprog);
650 kfree(code);
651
652 return err;
640 } 653 }
641 case PPPIOCSACTIVE: 654 case PPPIOCSACTIVE:
642 { 655 {
656 struct sock_fprog fprog;
643 struct sock_filter *code; 657 struct sock_filter *code;
644 int len = get_filter(argp, &code); 658 int err, len = get_filter(argp, &code);
659
645 if (len < 0) 660 if (len < 0)
646 return len; 661 return len;
647 kfree(is->active_filter); 662
648 is->active_filter = code; 663 fprog.len = len;
649 is->active_len = len; 664 fprog.filter = code;
650 break; 665
666 if (is->active_filter)
667 sk_unattached_filter_destroy(is->active_filter);
668 err = sk_unattached_filter_create(&is->active_filter, &fprog);
669 kfree(code);
670
671 return err;
651 } 672 }
652#endif /* CONFIG_IPPP_FILTER */ 673#endif /* CONFIG_IPPP_FILTER */
653 default: 674 default:
@@ -1147,14 +1168,14 @@ isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *
1147 } 1168 }
1148 1169
1149 if (is->pass_filter 1170 if (is->pass_filter
1150 && sk_run_filter(skb, is->pass_filter) == 0) { 1171 && SK_RUN_FILTER(is->pass_filter, skb) == 0) {
1151 if (is->debug & 0x2) 1172 if (is->debug & 0x2)
1152 printk(KERN_DEBUG "IPPP: inbound frame filtered.\n"); 1173 printk(KERN_DEBUG "IPPP: inbound frame filtered.\n");
1153 kfree_skb(skb); 1174 kfree_skb(skb);
1154 return; 1175 return;
1155 } 1176 }
1156 if (!(is->active_filter 1177 if (!(is->active_filter
1157 && sk_run_filter(skb, is->active_filter) == 0)) { 1178 && SK_RUN_FILTER(is->active_filter, skb) == 0)) {
1158 if (is->debug & 0x2) 1179 if (is->debug & 0x2)
1159 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); 1180 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n");
1160 lp->huptimer = 0; 1181 lp->huptimer = 0;
@@ -1293,14 +1314,14 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
1293 } 1314 }
1294 1315
1295 if (ipt->pass_filter 1316 if (ipt->pass_filter
1296 && sk_run_filter(skb, ipt->pass_filter) == 0) { 1317 && SK_RUN_FILTER(ipt->pass_filter, skb) == 0) {
1297 if (ipt->debug & 0x4) 1318 if (ipt->debug & 0x4)
1298 printk(KERN_DEBUG "IPPP: outbound frame filtered.\n"); 1319 printk(KERN_DEBUG "IPPP: outbound frame filtered.\n");
1299 kfree_skb(skb); 1320 kfree_skb(skb);
1300 goto unlock; 1321 goto unlock;
1301 } 1322 }
1302 if (!(ipt->active_filter 1323 if (!(ipt->active_filter
1303 && sk_run_filter(skb, ipt->active_filter) == 0)) { 1324 && SK_RUN_FILTER(ipt->active_filter, skb) == 0)) {
1304 if (ipt->debug & 0x4) 1325 if (ipt->debug & 0x4)
1305 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); 1326 printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n");
1306 lp->huptimer = 0; 1327 lp->huptimer = 0;
@@ -1490,9 +1511,9 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
1490 } 1511 }
1491 1512
1492 drop |= is->pass_filter 1513 drop |= is->pass_filter
1493 && sk_run_filter(skb, is->pass_filter) == 0; 1514 && SK_RUN_FILTER(is->pass_filter, skb) == 0;
1494 drop |= is->active_filter 1515 drop |= is->active_filter
1495 && sk_run_filter(skb, is->active_filter) == 0; 1516 && SK_RUN_FILTER(is->active_filter, skb) == 0;
1496 1517
1497 skb_push(skb, IPPP_MAX_HEADER - 4); 1518 skb_push(skb, IPPP_MAX_HEADER - 4);
1498 return drop; 1519 return drop;