Skip to content

Commit 42cb0be

Browse files
committed
batman-adv: set the isolation mark in the skb if needed
If a broadcast packet is coming from a client marked as isolated, then mark the skb using the isolation mark so that netfilter (or any other application) can recognise them. The mark is written in the skb based on the mask value: only bits set in the mask are substitued by those in the mark value Signed-off-by: Antonio Quartulli <[email protected]> Signed-off-by: Marek Lindner <[email protected]>
1 parent eceb22a commit 42cb0be

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

net/batman-adv/soft-interface.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,23 @@ void batadv_interface_rx(struct net_device *soft_iface,
399399
batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
400400
ethhdr->h_source, vid);
401401

402-
if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest,
403-
vid))
402+
if (is_multicast_ether_addr(ethhdr->h_dest)) {
403+
/* set the mark on broadcast packets if AP isolation is ON and
404+
* the packet is coming from an "isolated" client
405+
*/
406+
if (batadv_vlan_ap_isola_get(bat_priv, vid) &&
407+
batadv_tt_global_is_isolated(bat_priv, ethhdr->h_source,
408+
vid)) {
409+
/* save bits in skb->mark not covered by the mask and
410+
* apply the mark on the rest
411+
*/
412+
skb->mark &= ~bat_priv->isolation_mark_mask;
413+
skb->mark |= bat_priv->isolation_mark;
414+
}
415+
} else if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source,
416+
ethhdr->h_dest, vid)) {
404417
goto dropped;
418+
}
405419

406420
netif_rx(skb);
407421
goto out;

net/batman-adv/translation-table.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,3 +3577,29 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
35773577

35783578
return 1;
35793579
}
3580+
3581+
/**
3582+
* batadv_tt_global_is_isolated - check if a client is marked as isolated
3583+
* @bat_priv: the bat priv with all the soft interface information
3584+
* @addr: the mac address of the client
3585+
* @vid: the identifier of the VLAN where this client is connected
3586+
*
3587+
* Returns true if the client is marked with the TT_CLIENT_ISOLA flag, false
3588+
* otherwise
3589+
*/
3590+
bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
3591+
const uint8_t *addr, unsigned short vid)
3592+
{
3593+
struct batadv_tt_global_entry *tt;
3594+
bool ret;
3595+
3596+
tt = batadv_tt_global_hash_find(bat_priv, addr, vid);
3597+
if (!tt)
3598+
return false;
3599+
3600+
ret = tt->common.flags & BATADV_TT_CLIENT_ISOLA;
3601+
3602+
batadv_tt_global_entry_free_ref(tt);
3603+
3604+
return ret;
3605+
}

net/batman-adv/translation-table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
4848
struct batadv_orig_node *orig_node,
4949
const unsigned char *addr,
5050
unsigned short vid);
51+
bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
52+
const uint8_t *addr, unsigned short vid);
5153

5254
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */

0 commit comments

Comments
 (0)