* [PATCH net-next] vrf: handle CONFIG_IPV6 not set for vrf_add_mac_header_if_unset()
@ 2020-12-08 17:52 Andrea Mayer
2020-12-08 19:51 ` David Ahern
0 siblings, 1 reply; 3+ messages in thread
From: Andrea Mayer @ 2020-12-08 17:52 UTC (permalink / raw
To: David S. Miller, David Ahern, Jakub Kicinski, Shrijeet Mukherjee,
netdev, linux-kernel
Cc: Stefano Salsano, Paolo Lungaroni, Ahmed Abdelsalam, Andrea Mayer,
kernel test robot
The vrf_add_mac_header_if_unset() is defined within a conditional
compilation block which depends on the CONFIG_IPV6 macro.
However, the vrf_add_mac_header_if_unset() needs to be called also by IPv4
related code and when the CONFIG_IPV6 is not set, this function is missing.
As a consequence, the build process stops reporting the error:
ERROR: implicit declaration of function 'vrf_add_mac_header_if_unset'
The problem is solved by *only* moving functions
vrf_add_mac_header_if_unset() and vrf_prepare_mac_header() out of the
conditional block.
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 0489390882202 ("vrf: add mac header for tunneled packets when sniffer is attached")
Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
---
drivers/net/vrf.c | 110 +++++++++++++++++++++++-----------------------
1 file changed, 55 insertions(+), 55 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 259d5cbacf2c..571bd03ebd81 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -1237,6 +1237,61 @@ static struct sk_buff *vrf_rcv_nfhook(u8 pf, unsigned int hook,
return skb;
}
+static int vrf_prepare_mac_header(struct sk_buff *skb,
+ struct net_device *vrf_dev, u16 proto)
+{
+ struct ethhdr *eth;
+ int err;
+
+ /* in general, we do not know if there is enough space in the head of
+ * the packet for hosting the mac header.
+ */
+ err = skb_cow_head(skb, LL_RESERVED_SPACE(vrf_dev));
+ if (unlikely(err))
+ /* no space in the skb head */
+ return -ENOBUFS;
+
+ __skb_push(skb, ETH_HLEN);
+ eth = (struct ethhdr *)skb->data;
+
+ skb_reset_mac_header(skb);
+
+ /* we set the ethernet destination and the source addresses to the
+ * address of the VRF device.
+ */
+ ether_addr_copy(eth->h_dest, vrf_dev->dev_addr);
+ ether_addr_copy(eth->h_source, vrf_dev->dev_addr);
+ eth->h_proto = htons(proto);
+
+ /* the destination address of the Ethernet frame corresponds to the
+ * address set on the VRF interface; therefore, the packet is intended
+ * to be processed locally.
+ */
+ skb->protocol = eth->h_proto;
+ skb->pkt_type = PACKET_HOST;
+
+ skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
+
+ skb_pull_inline(skb, ETH_HLEN);
+
+ return 0;
+}
+
+/* prepare and add the mac header to the packet if it was not set previously.
+ * In this way, packet sniffers such as tcpdump can parse the packet correctly.
+ * If the mac header was already set, the original mac header is left
+ * untouched and the function returns immediately.
+ */
+static int vrf_add_mac_header_if_unset(struct sk_buff *skb,
+ struct net_device *vrf_dev,
+ u16 proto)
+{
+ if (skb_mac_header_was_set(skb))
+ return 0;
+
+ return vrf_prepare_mac_header(skb, vrf_dev, proto);
+}
+
#if IS_ENABLED(CONFIG_IPV6)
/* neighbor handling is done with actual device; do not want
* to flip skb->dev for those ndisc packets. This really fails
@@ -1310,61 +1365,6 @@ static void vrf_ip6_input_dst(struct sk_buff *skb, struct net_device *vrf_dev,
skb_dst_set(skb, &rt6->dst);
}
-static int vrf_prepare_mac_header(struct sk_buff *skb,
- struct net_device *vrf_dev, u16 proto)
-{
- struct ethhdr *eth;
- int err;
-
- /* in general, we do not know if there is enough space in the head of
- * the packet for hosting the mac header.
- */
- err = skb_cow_head(skb, LL_RESERVED_SPACE(vrf_dev));
- if (unlikely(err))
- /* no space in the skb head */
- return -ENOBUFS;
-
- __skb_push(skb, ETH_HLEN);
- eth = (struct ethhdr *)skb->data;
-
- skb_reset_mac_header(skb);
-
- /* we set the ethernet destination and the source addresses to the
- * address of the VRF device.
- */
- ether_addr_copy(eth->h_dest, vrf_dev->dev_addr);
- ether_addr_copy(eth->h_source, vrf_dev->dev_addr);
- eth->h_proto = htons(proto);
-
- /* the destination address of the Ethernet frame corresponds to the
- * address set on the VRF interface; therefore, the packet is intended
- * to be processed locally.
- */
- skb->protocol = eth->h_proto;
- skb->pkt_type = PACKET_HOST;
-
- skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
-
- skb_pull_inline(skb, ETH_HLEN);
-
- return 0;
-}
-
-/* prepare and add the mac header to the packet if it was not set previously.
- * In this way, packet sniffers such as tcpdump can parse the packet correctly.
- * If the mac header was already set, the original mac header is left
- * untouched and the function returns immediately.
- */
-static int vrf_add_mac_header_if_unset(struct sk_buff *skb,
- struct net_device *vrf_dev,
- u16 proto)
-{
- if (skb_mac_header_was_set(skb))
- return 0;
-
- return vrf_prepare_mac_header(skb, vrf_dev, proto);
-}
-
static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,
struct sk_buff *skb)
{
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vrf: handle CONFIG_IPV6 not set for vrf_add_mac_header_if_unset()
2020-12-08 17:52 [PATCH net-next] vrf: handle CONFIG_IPV6 not set for vrf_add_mac_header_if_unset() Andrea Mayer
@ 2020-12-08 19:51 ` David Ahern
2020-12-09 20:04 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2020-12-08 19:51 UTC (permalink / raw
To: Andrea Mayer, David S. Miller, David Ahern, Jakub Kicinski,
Shrijeet Mukherjee, netdev, linux-kernel
Cc: Stefano Salsano, Paolo Lungaroni, Ahmed Abdelsalam,
kernel test robot
On 12/8/20 10:52 AM, Andrea Mayer wrote:
> The vrf_add_mac_header_if_unset() is defined within a conditional
> compilation block which depends on the CONFIG_IPV6 macro.
> However, the vrf_add_mac_header_if_unset() needs to be called also by IPv4
> related code and when the CONFIG_IPV6 is not set, this function is missing.
> As a consequence, the build process stops reporting the error:
>
> ERROR: implicit declaration of function 'vrf_add_mac_header_if_unset'
>
> The problem is solved by *only* moving functions
> vrf_add_mac_header_if_unset() and vrf_prepare_mac_header() out of the
> conditional block.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 0489390882202 ("vrf: add mac header for tunneled packets when sniffer is attached")
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
> drivers/net/vrf.c | 110 +++++++++++++++++++++++-----------------------
> 1 file changed, 55 insertions(+), 55 deletions(-)
>
I should have caught that in my review.
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vrf: handle CONFIG_IPV6 not set for vrf_add_mac_header_if_unset()
2020-12-08 19:51 ` David Ahern
@ 2020-12-09 20:04 ` Jakub Kicinski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-12-09 20:04 UTC (permalink / raw
To: David Ahern, Andrea Mayer
Cc: David S. Miller, David Ahern, Shrijeet Mukherjee, netdev,
linux-kernel, Stefano Salsano, Paolo Lungaroni, Ahmed Abdelsalam,
kernel test robot
On Tue, 8 Dec 2020 12:51:55 -0700 David Ahern wrote:
> On 12/8/20 10:52 AM, Andrea Mayer wrote:
> > The vrf_add_mac_header_if_unset() is defined within a conditional
> > compilation block which depends on the CONFIG_IPV6 macro.
> > However, the vrf_add_mac_header_if_unset() needs to be called also by IPv4
> > related code and when the CONFIG_IPV6 is not set, this function is missing.
> > As a consequence, the build process stops reporting the error:
> >
> > ERROR: implicit declaration of function 'vrf_add_mac_header_if_unset'
> >
> > The problem is solved by *only* moving functions
> > vrf_add_mac_header_if_unset() and vrf_prepare_mac_header() out of the
> > conditional block.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Fixes: 0489390882202 ("vrf: add mac header for tunneled packets when sniffer is attached")
> > Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
>
> I should have caught that in my review.
>
> Reviewed-by: David Ahern <dsahern@kernel.org>
Applied, thank you!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-09 20:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-08 17:52 [PATCH net-next] vrf: handle CONFIG_IPV6 not set for vrf_add_mac_header_if_unset() Andrea Mayer
2020-12-08 19:51 ` David Ahern
2020-12-09 20:04 ` 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.