On Wed, 14 Mar 2018 12:01:19 +0100 Rafał Miłecki <zajec5@xxxxxxxxx> wrote: > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c > index 19048526b4af..db6987015fb1 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c > @@ -230,6 +230,34 @@ static void brcmf_netdev_set_multicast_list(struct net_device *ndev) > schedule_work(&ifp->multicast_work); > } > > +/** > + * brcmf_skb_is_iapp - checks if skb is an IAPP packet > + * > + * @skb: skb to check > + */ > +static bool brcmf_skb_is_iapp(struct sk_buff *skb) > +{ > + const u8 iapp_l2_update_packet[6] __aligned(2) = { > + 0x00, 0x01, 0xaf, 0x81, 0x01, 0x00, > + }; > + unsigned char *eth_data = skb_mac_header(skb) + ETH_HLEN; > +#if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) > + const u16 *a = (const u16 *)eth_data; > + const u16 *b = (const u16 *)iapp_l2_update_packet; > +#endif > + > + if (skb->len - skb->mac_len != 6 || > + !is_multicast_ether_addr(eth_hdr(skb)->h_dest)) > + return false; > + > +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) > + return !(((*(const u32 *)eth_data) ^ (*(const u32 *)iapp_l2_update_packet)) | > + ((*(const u16 *)(eth_data + 4)) ^ (*(const u16 *)(iapp_l2_update_packet + 4)))); > +#else > + return !((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])); > +#endif > +} > + > static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, > struct net_device *ndev) > { > @@ -250,6 +278,12 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, > goto done; > } > > + if (!IS_ENABLED(CONFIG_BRCMFMAC_IAPP) && brcmf_skb_is_iapp(skb)) { > + dev_kfree_skb(skb); > + ret = -EINVAL; > + goto done; > + } > + The usual way to handle config options in kernel is either inline stub function or #define #ifdef CONFIG_BRFMMAC_IAPP static bool brcmf_skb_is_app(...) { real code } #else #define brcmf_skb_is_app (false) #endif