netfilter: xtables: clean up xt_mac match routine
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
This commit is contained in:
@@ -27,13 +27,15 @@ MODULE_ALIAS("ip6t_mac");
|
|||||||
static bool mac_mt(const struct sk_buff *skb, const struct xt_match_param *par)
|
static bool mac_mt(const struct sk_buff *skb, const struct xt_match_param *par)
|
||||||
{
|
{
|
||||||
const struct xt_mac_info *info = par->matchinfo;
|
const struct xt_mac_info *info = par->matchinfo;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
/* Is mac pointer valid? */
|
if (skb_mac_header(skb) < skb->head)
|
||||||
return skb_mac_header(skb) >= skb->head &&
|
return false;
|
||||||
skb_mac_header(skb) + ETH_HLEN <= skb->data
|
if (skb_mac_header(skb) + ETH_HLEN > skb->data)
|
||||||
/* If so, compare... */
|
return false;
|
||||||
&& ((!compare_ether_addr(eth_hdr(skb)->h_source, info->srcaddr))
|
ret = compare_ether_addr(eth_hdr(skb)->h_source, info->srcaddr) == 0;
|
||||||
^ info->invert);
|
ret ^= info->invert;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct xt_match mac_mt_reg __read_mostly = {
|
static struct xt_match mac_mt_reg __read_mostly = {
|
||||||
|
Reference in New Issue
Block a user