From: Simon Wunderlich <sw@simonwunderlich.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [PATCH v6 1/3] batman-adv: mcast: implement multicast packet reception and forwarding
Date: Mon, 14 Aug 2023 17:53:38 +0200 [thread overview]
Message-ID: <38662377.10thIPus4b@prime> (raw)
In-Reply-To: <2296108.bB369e8A3T@prime>
[-- Attachment #1: Type: text/plain, Size: 4717 bytes --]
On Monday, August 14, 2023 5:35:28 PM CEST Simon Wunderlich wrote:
> I've read through that multiple times now, and I don't understand why
> next_dest isn't getting incremented within each iteration in the same way
> as dest. Is this a bug or am I missing something? Might be nicer to use one
> counter which is increased instead of two pointeres, e.g. &dest[counter]
> and &next_dest[counter] or similar to avoid those kind of bugs.
> > [...]
Discussed with Sven, next_dest is actually the iterator so it should be
incremented at the other place.
I still think this is very hard to read, both Sven and I spent quite some time
with pen and paper to understand this function. I would appreciate if it could
be simplified.
> > +/**
> > + * batadv_mcast_forw_tracker_tvlv_handler() - handle an mcast tracker
> > tvlv
> > + * @bat_priv: the bat priv with all the soft interface information
> > + * @skb: the received batman-adv multicast packet
> > + *
> > + * Parses the tracker TVLV of an incoming batman-adv multicast packet and
> > + * forwards the packet as indicated in this TVLV.
> > + *
> > + * Caller needs to set the skb network header to the start of the
> > multicast + * tracker TVLV (excluding the generic TVLV header) and the
> > skb transport header + * to the next byte after this multicast tracker
> > TVLV.
> > + *
> > + * Caller needs to free the skb.
> > + *
> > + * Return: NET_RX_SUCCESS or NET_RX_DROP on success or a negative error
> > + * code on failure. NET_RX_SUCCESS if the received packet is supposed to
> > be + * decapsulated and forwarded to the own soft interface, NET_RX_DROP
> > otherwise. + */
> > +int batadv_mcast_forw_tracker_tvlv_handler(struct batadv_priv *bat_priv,
> > + struct sk_buff *skb)
> > +{
> > + return batadv_mcast_forw_packet(bat_priv, skb, false);
> > +}
> > diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
> > index 34903df4fe93..e46ce83c516a 100644
> > --- a/net/batman-adv/originator.c
> > +++ b/net/batman-adv/originator.c
> > @@ -942,6 +942,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct
> > batadv_priv *bat_priv, #ifdef CONFIG_BATMAN_ADV_MCAST
> > orig_node->mcast_flags = BATADV_MCAST_WANT_NO_RTR4;
> > orig_node->mcast_flags |= BATADV_MCAST_WANT_NO_RTR6;
> > + orig_node->mcast_flags |= BATADV_MCAST_HAVE_MC_PTYPE_CAPA;
> > INIT_HLIST_NODE(&orig_node->mcast_want_all_unsnoopables_node);
> > INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv4_node);
> > INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv6_node);
> > diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
> > index 163cd43c4821..f1061985149f 100644
> > --- a/net/batman-adv/routing.c
> > +++ b/net/batman-adv/routing.c
> > @@ -1270,3 +1270,73 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
> > batadv_orig_node_put(orig_node);
> > return ret;
> > }
> > +
> > +#ifdef CONFIG_BATMAN_ADV_MCAST
> > +/**
> > + * batadv_recv_mcast_packet() - process received batman-adv multicast
> > packet + * @skb: the received batman-adv multicast packet
> > + * @recv_if: interface that the skb is received on
> > + *
> > + * Parses the given, received batman-adv multicast packet. Depending on
> > the + * contents of its TVLV forwards it and/or decapsulates it to hand
> > it to the + * soft interface.
> > + *
> > + * Return: NET_RX_DROP if the skb is not consumed, NET_RX_SUCCESS
> > otherwise. + */
> > +int batadv_recv_mcast_packet(struct sk_buff *skb,
> > + struct batadv_hard_iface *recv_if)
> > +{
> > + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
> > + struct batadv_mcast_packet *mcast_packet;
> > + int hdr_size = sizeof(*mcast_packet);
> > + unsigned char *tvlv_buff;
> > + int ret = NET_RX_DROP;
> > + u16 tvlv_buff_len;
> > +
> > + if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0)
> > + goto free_skb;
> > +
> > + /* create a copy of the skb, if needed, to modify it. */
> > + if (skb_cow(skb, ETH_HLEN) < 0)
> > + goto free_skb;
> > +
> > + /* packet needs to be linearized to access the tvlv content */
> > + if (skb_linearize(skb) < 0)
> > + goto free_skb;
> > +
> > + mcast_packet = (struct batadv_mcast_packet *)skb->data;
> > + if (mcast_packet->ttl-- < 2)
> > + goto free_skb;
>
> More of a nit (since we do the same check in broadcasts), but if ttl == 0 on
> the incoming packet, then we will actually forward it with ttl =255 and
> that's a bit stupid ...
Mistake on my end on this one, the original value should be used for the
comparison so this is okay.
Cheers,
Simon
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-08-14 15:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 4:35 [PATCH v6 0/3] Implementation of a Stateless Multicast Packet Type Linus Lüssing
2023-07-20 4:35 ` [PATCH v6 1/3] batman-adv: mcast: implement multicast packet reception and forwarding Linus Lüssing
2023-07-28 17:52 ` Sven Eckelmann
2023-08-14 15:35 ` Simon Wunderlich
2023-08-14 15:53 ` Simon Wunderlich [this message]
2023-07-20 4:35 ` [PATCH v6 2/3] batman-adv: mcast: implement multicast packet generation Linus Lüssing
2023-07-29 10:49 ` Sven Eckelmann
2023-07-20 4:35 ` [PATCH v6 3/3] batman-adv: mcast: shrink tracker packet after scrubbing Linus Lüssing
2023-07-29 11:11 ` Sven Eckelmann
2023-08-14 15:56 ` Simon Wunderlich
2023-07-29 11:11 ` [PATCH v6 0/3] Implementation of a Stateless Multicast Packet Type Sven Eckelmann
2023-08-14 16:05 ` Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38662377.10thIPus4b@prime \
--to=sw@simonwunderlich.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).