All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] ipmr: support IP_PKTINFO on cache report IGMP msg
@ 2023-12-13 16:19 Leone Fernando
  2023-12-14 13:16 ` Eric Dumazet
  2023-12-19  0:00 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Leone Fernando @ 2023-12-13 16:19 UTC (permalink / raw)
  To: davem, dsahern, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, leone4fernando

In order to support IP_PKTINFO on those packets, we need to call
ipv4_pktinfo_prepare.

When sending mrouted/pimd daemons a cache report IGMP msg, it is
unnecessary to set dst on the newly created skb.
It used to be necessary on older versions until
commit d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference") which
changed the way IP_PKTINFO struct is been retrieved.

Changes from v1:
1. Undo changes in ipv4_pktinfo_prepare function. use it directly
   and copy the control block.

Fixes: d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference")
Signed-off-by: Leone Fernando <leone4fernando@gmail.com>
---
 net/ipv4/ipmr.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 9e222a57bc2b..0063a237253b 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1025,6 +1025,10 @@ static int ipmr_cache_report(const struct mr_table *mrt,
 	struct sk_buff *skb;
 	int ret;

+	mroute_sk = rcu_dereference(mrt->mroute_sk);
+	if (!mroute_sk)
+		return -EINVAL;
+
 	if (assert == IGMPMSG_WHOLEPKT || assert == IGMPMSG_WRVIFWHOLE)
 		skb = skb_realloc_headroom(pkt, sizeof(struct iphdr));
 	else
@@ -1069,7 +1073,8 @@ static int ipmr_cache_report(const struct mr_table *mrt,
 		msg = (struct igmpmsg *)skb_network_header(skb);
 		msg->im_vif = vifi;
 		msg->im_vif_hi = vifi >> 8;
-		skb_dst_set(skb, dst_clone(skb_dst(pkt)));
+		ipv4_pktinfo_prepare(mroute_sk, pkt);
+		memcpy(skb->cb, pkt->cb, sizeof(skb->cb));
 		/* Add our header */
 		igmp = skb_put(skb, sizeof(struct igmphdr));
 		igmp->type = assert;
@@ -1079,12 +1084,6 @@ static int ipmr_cache_report(const struct mr_table *mrt,
 		skb->transport_header = skb->network_header;
 	}

-	mroute_sk = rcu_dereference(mrt->mroute_sk);
-	if (!mroute_sk) {
-		kfree_skb(skb);
-		return -EINVAL;
-	}
-
 	igmpmsg_netlink_event(mrt, skb);

 	/* Deliver to mrouted */
--
2.34.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] ipmr: support IP_PKTINFO on cache report IGMP msg
  2023-12-13 16:19 [PATCH net-next v2] ipmr: support IP_PKTINFO on cache report IGMP msg Leone Fernando
@ 2023-12-14 13:16 ` Eric Dumazet
  2023-12-19  0:00 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2023-12-14 13:16 UTC (permalink / raw)
  To: Leone Fernando; +Cc: davem, dsahern, kuba, pabeni, netdev, linux-kernel

On Wed, Dec 13, 2023 at 5:28 PM Leone Fernando <leone4fernando@gmail.com> wrote:
>
> In order to support IP_PKTINFO on those packets, we need to call
> ipv4_pktinfo_prepare.
>
> When sending mrouted/pimd daemons a cache report IGMP msg, it is
> unnecessary to set dst on the newly created skb.
> It used to be necessary on older versions until
> commit d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference") which
> changed the way IP_PKTINFO struct is been retrieved.
>
> Changes from v1:
> 1. Undo changes in ipv4_pktinfo_prepare function. use it directly
>    and copy the control block.
>
> Fixes: d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference")
> Signed-off-by: Leone Fernando <leone4fernando@gmail.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] ipmr: support IP_PKTINFO on cache report IGMP msg
  2023-12-13 16:19 [PATCH net-next v2] ipmr: support IP_PKTINFO on cache report IGMP msg Leone Fernando
  2023-12-14 13:16 ` Eric Dumazet
@ 2023-12-19  0:00 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-12-19  0:00 UTC (permalink / raw)
  To: Leone Fernando; +Cc: davem, dsahern, edumazet, pabeni, netdev, linux-kernel

On Wed, 13 Dec 2023 17:19:35 +0100 Leone Fernando wrote:
> In order to support IP_PKTINFO on those packets, we need to call
> ipv4_pktinfo_prepare.
> 
> When sending mrouted/pimd daemons a cache report IGMP msg, it is
> unnecessary to set dst on the newly created skb.
> It used to be necessary on older versions until
> commit d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference") which
> changed the way IP_PKTINFO struct is been retrieved.
> 
> Changes from v1:
> 1. Undo changes in ipv4_pktinfo_prepare function. use it directly
>    and copy the control block.
> 
> Fixes: d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference")
> Signed-off-by: Leone Fernando <leone4fernando@gmail.com>

Applied to net-next, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-19  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 16:19 [PATCH net-next v2] ipmr: support IP_PKTINFO on cache report IGMP msg Leone Fernando
2023-12-14 13:16 ` Eric Dumazet
2023-12-19  0:00 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.