On Thursday, 20 July 2023 06:35:54 CEST Linus Lüssing wrote:
Implement the preparation of a batman-adv multicast packet and use this under certain conditions.
For one thing this implements the capability to push a complete batman-adv multicast packet header, including a tracker TVLV with all originator destinations that have signaled interest in it, onto a given ethernet frame with an IP multicast packet inside.
For another checks are implemented to determine if encapsulating a multicast packet in this new batman-adv multicast packet type and using it is feasible. Those checks are:
- Have all nodes signaled that they are capable of handling the new batman-adv multicast packet type?
- Do all active hard interfaces of all nodes, including us, have an MTU of at least 1280 bytes?
- Does a complete multicast packet header with all its destination addresses fit onto the given multicast packet / ethernet frame and does not exceed 1280 bytes?
If all checks passed then the new batman-adv multicast packet type will be used for transmission and distribution. Otherwise we fall back to one or more batman-adv unicast packet transmissions, if possible. Or if not possible we will fall back to classic flooding through a batman-adv broadcast packet.
Signed-off-by: Linus Lüssing linus.luessing@c0d3.blue
net/batman-adv/multicast.c | 79 +++- net/batman-adv/multicast.h | 25 +- net/batman-adv/multicast_forw.c | 727 ++++++++++++++++++++++++++++++++ net/batman-adv/soft-interface.c | 6 +- net/batman-adv/types.h | 6 + 5 files changed, 835 insertions(+), 8 deletions(-)
Acked-by: Sven Eckelmann sven@narfation.org
+/**
- batadv_mcast_forw_scrape() - remove bytes within skb data
- @skb: the skb to remove bytes from
- @offset: the offset from the skb data from which to scrape
- @len: the amount of bytes to scrape starting from the offset
- Scrapes/removes len bytes from the given skb at the given offset from the
- skb data.
- Caller needs to ensure that the region from the skb data's start up
- to/including the to be removed bytes are linearized.
- */
+static void batadv_mcast_forw_scrape(struct sk_buff *skb,
unsigned short offset,
unsigned short len)
+{
- char *to = skb_pull(skb, len), *from = to - len;
- memmove(to, from, offset);
+}
Just because I remembered it when reading a comment: SKB_LINEAR_ASSERT(skb) might be a good idea in places like this. Not all over the place but actually in the code which operates on the buffer and assumes the skbuff to be linearized. skb_put would do such a check (because it is a put at the end of the skb) but not an skb_pull.
Kind regards, Sven