1414#include <linux/if_arp.h>
1515#include <linux/module.h>
1616
17- static int ebt_mac_wormhash_contains (const struct ebt_mac_wormhash * wh ,
18- const char * mac , __be32 ip )
17+ static bool ebt_mac_wormhash_contains (const struct ebt_mac_wormhash * wh ,
18+ const char * mac , __be32 ip )
1919{
2020 /* You may be puzzled as to how this code works.
2121 * Some tricks were used, refer to
@@ -33,23 +33,19 @@ static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh,
3333 if (ip ) {
3434 for (i = start ; i < limit ; i ++ ) {
3535 p = & wh -> pool [i ];
36- if (cmp [1 ] == p -> cmp [1 ] && cmp [0 ] == p -> cmp [0 ]) {
37- if (p -> ip == 0 || p -> ip == ip ) {
38- return 1 ;
39- }
40- }
36+ if (cmp [1 ] == p -> cmp [1 ] && cmp [0 ] == p -> cmp [0 ])
37+ if (p -> ip == 0 || p -> ip == ip )
38+ return true;
4139 }
4240 } else {
4341 for (i = start ; i < limit ; i ++ ) {
4442 p = & wh -> pool [i ];
45- if (cmp [1 ] == p -> cmp [1 ] && cmp [0 ] == p -> cmp [0 ]) {
46- if (p -> ip == 0 ) {
47- return 1 ;
48- }
49- }
43+ if (cmp [1 ] == p -> cmp [1 ] && cmp [0 ] == p -> cmp [0 ])
44+ if (p -> ip == 0 )
45+ return true;
5046 }
5147 }
52- return 0 ;
48+ return false ;
5349}
5450
5551static int ebt_mac_wormhash_check_integrity (const struct ebt_mac_wormhash
@@ -131,10 +127,10 @@ static int get_ip_src(const struct sk_buff *skb, __be32 *addr)
131127 return 0 ;
132128}
133129
134- static int ebt_filter_among (const struct sk_buff * skb ,
135- const struct net_device * in ,
136- const struct net_device * out , const void * data ,
137- unsigned int datalen )
130+ static bool ebt_filter_among (const struct sk_buff * skb ,
131+ const struct net_device * in ,
132+ const struct net_device * out , const void * data ,
133+ unsigned int datalen )
138134{
139135 const struct ebt_among_info * info = data ;
140136 const char * dmac , * smac ;
@@ -147,34 +143,34 @@ static int ebt_filter_among(const struct sk_buff *skb,
147143 if (wh_src ) {
148144 smac = eth_hdr (skb )-> h_source ;
149145 if (get_ip_src (skb , & sip ))
150- return EBT_NOMATCH ;
146+ return false ;
151147 if (!(info -> bitmask & EBT_AMONG_SRC_NEG )) {
152148 /* we match only if it contains */
153149 if (!ebt_mac_wormhash_contains (wh_src , smac , sip ))
154- return EBT_NOMATCH ;
150+ return false ;
155151 } else {
156152 /* we match only if it DOES NOT contain */
157153 if (ebt_mac_wormhash_contains (wh_src , smac , sip ))
158- return EBT_NOMATCH ;
154+ return false ;
159155 }
160156 }
161157
162158 if (wh_dst ) {
163159 dmac = eth_hdr (skb )-> h_dest ;
164160 if (get_ip_dst (skb , & dip ))
165- return EBT_NOMATCH ;
161+ return false ;
166162 if (!(info -> bitmask & EBT_AMONG_DST_NEG )) {
167163 /* we match only if it contains */
168164 if (!ebt_mac_wormhash_contains (wh_dst , dmac , dip ))
169- return EBT_NOMATCH ;
165+ return false ;
170166 } else {
171167 /* we match only if it DOES NOT contain */
172168 if (ebt_mac_wormhash_contains (wh_dst , dmac , dip ))
173- return EBT_NOMATCH ;
169+ return false ;
174170 }
175171 }
176172
177- return EBT_MATCH ;
173+ return true ;
178174}
179175
180176static bool
0 commit comments