netfilter: ebtables: fix one wrong return value
[safe/jmp/linux-2.6] / net / bridge / netfilter / ebt_802_3.c
1 /*
2  * 802_3
3  *
4  * Author:
5  * Chris Vitale csv@bluetail.com
6  *
7  * May 2003
8  *
9  */
10 #include <linux/module.h>
11 #include <linux/netfilter/x_tables.h>
12 #include <linux/netfilter_bridge/ebtables.h>
13 #include <linux/netfilter_bridge/ebt_802_3.h>
14
15 static bool
16 ebt_802_3_mt(const struct sk_buff *skb, const struct net_device *in,
17              const struct net_device *out, const struct xt_match *match,
18              const void *data, int offset, unsigned int protoff, bool *hotdrop)
19 {
20         const struct ebt_802_3_info *info = data;
21         const struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
22         __be16 type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
23
24         if (info->bitmask & EBT_802_3_SAP) {
25                 if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP))
26                         return false;
27                 if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
28                         return false;
29         }
30
31         if (info->bitmask & EBT_802_3_TYPE) {
32                 if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
33                         return false;
34                 if (FWINV(info->type != type, EBT_802_3_TYPE))
35                         return false;
36         }
37
38         return true;
39 }
40
41 static bool
42 ebt_802_3_mt_check(const char *table, const void *entry,
43                    const struct xt_match *match, void *data,
44                    unsigned int hook_mask)
45 {
46         const struct ebt_802_3_info *info = data;
47
48         if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
49                 return false;
50
51         return true;
52 }
53
54 static struct xt_match ebt_802_3_mt_reg __read_mostly = {
55         .name           = "802_3",
56         .revision       = 0,
57         .family         = NFPROTO_BRIDGE,
58         .match          = ebt_802_3_mt,
59         .checkentry     = ebt_802_3_mt_check,
60         .matchsize      = XT_ALIGN(sizeof(struct ebt_802_3_info)),
61         .me             = THIS_MODULE,
62 };
63
64 static int __init ebt_802_3_init(void)
65 {
66         return xt_register_match(&ebt_802_3_mt_reg);
67 }
68
69 static void __exit ebt_802_3_fini(void)
70 {
71         xt_unregister_match(&ebt_802_3_mt_reg);
72 }
73
74 module_init(ebt_802_3_init);
75 module_exit(ebt_802_3_fini);
76 MODULE_DESCRIPTION("Ebtables: DSAP/SSAP field and SNAP type matching");
77 MODULE_LICENSE("GPL");