From: Sven Eckelmann <[email protected]>

batadv_mcast_forw_mode_by_count() pushs the skb->data for BATADV_FORW_MCAST
forwarding via batadv_mcast_forw_mcsend(). But the
batadv_skb_set_priority() expects the ethernet header directly before
(skb->data + offset). With the moved skb->data, just some random data would
be accessed to get the priority data.

Move the batadv_skb_set_priority() before the decision about the handling
multicast packets and potential header modifications.

Cc: [email protected]
Fixes: 90039133221e ("batman-adv: mcast: implement multicast packet generation")
Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Simon Wunderlich <[email protected]>
---
 net/batman-adv/mesh-interface.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/mesh-interface.c b/net/batman-adv/mesh-interface.c
index 1dc6cfae9e9ae..48bbb28d4576f 100644
--- a/net/batman-adv/mesh-interface.c
+++ b/net/batman-adv/mesh-interface.c
@@ -260,6 +260,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
        if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
                goto dropped;
 
+       batadv_skb_set_priority(skb, 0);
+
        gw_mode = READ_ONCE(bat_priv->gw.mode);
        if (is_multicast_ether_addr(ethhdr->h_dest)) {
                /* if gw mode is off, broadcast every packet */
@@ -293,6 +295,9 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 
 send:
                if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) {
+                       /* WARNING batadv_mcast_forw_mode might add more headers
+                        * in front of the skb. and might even reallocate the 
skb
+                        */
                        forw_mode = batadv_mcast_forw_mode(bat_priv, skb, vid,
                                                           &mcast_is_routable);
                        switch (forw_mode) {
@@ -310,8 +315,6 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
                }
        }
 
-       batadv_skb_set_priority(skb, 0);
-
        /* ethernet packet should be broadcasted */
        if (do_bcast) {
                primary_if = batadv_primary_if_get_selected(bat_priv);
-- 
2.47.3

Reply via email to