All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] SRv6: SRH processing improvements
@ 2021-03-11 15:53 Julien Massonneau
  2021-03-11 15:53 ` [PATCH net-next 1/2] seg6: add support for IPv4 decapsulation in ipv6_srh_rcv() Julien Massonneau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Julien Massonneau @ 2021-03-11 15:53 UTC (permalink / raw)
  To: davem, dsahern, kuba, netdev, dlebrun; +Cc: Julien Massonneau

Add support for IPv4 decapsulation in ipv6_srh_rcv() and
ignore routing header with segments left equal to 0 for
seg6local actions that doesn't perfom decapsulation.

Julien Massonneau (2):
  seg6: add support for IPv4 decapsulation in ipv6_srh_rcv()
  seg6: ignore routing header with segments left equal to 0

 include/net/ipv6.h    |  1 +
 net/ipv6/exthdrs.c    |  5 +++--
 net/ipv6/seg6_local.c | 11 ++++-------
 3 files changed, 8 insertions(+), 9 deletions(-)


base-commit: 34bb975126419e86bc3b95e200dc41de6c6ca69c
-- 
2.29.2


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

* [PATCH net-next 1/2] seg6: add support for IPv4 decapsulation in ipv6_srh_rcv()
  2021-03-11 15:53 [PATCH net-next 0/2] SRv6: SRH processing improvements Julien Massonneau
@ 2021-03-11 15:53 ` Julien Massonneau
  2021-03-11 15:53 ` [PATCH net-next 2/2] seg6: ignore routing header with segments left equal to 0 Julien Massonneau
  2021-03-12  0:30 ` [PATCH net-next 0/2] SRv6: SRH processing improvements patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Julien Massonneau @ 2021-03-11 15:53 UTC (permalink / raw)
  To: davem, dsahern, kuba, netdev, dlebrun; +Cc: Julien Massonneau

As specified in IETF RFC 8754, section 4.3.1.2, if the upper layer
header is IPv4 or IPv6, perform IPv6 decapsulation and resubmit the
decapsulated packet to the IPv4 or IPv6 module.
Only IPv6 decapsulation was implemented. This patch adds support for IPv4
decapsulation.

Link: https://tools.ietf.org/html/rfc8754#section-4.3.1.2
Signed-off-by: Julien Massonneau <julien.massonneau@6wind.com>
---
 include/net/ipv6.h | 1 +
 net/ipv6/exthdrs.c | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index bd1f396cc9c7..448bf2b34759 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -30,6 +30,7 @@
  */
 
 #define NEXTHDR_HOP		0	/* Hop-by-hop option header. */
+#define NEXTHDR_IPV4		4	/* IPv4 in IPv6 */
 #define NEXTHDR_TCP		6	/* TCP segment. */
 #define NEXTHDR_UDP		17	/* UDP message. */
 #define NEXTHDR_IPV6		41	/* IPv6 in IPv6 */
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 6126f8bf94b3..56e479d158b7 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -381,7 +381,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
 
 looped_back:
 	if (hdr->segments_left == 0) {
-		if (hdr->nexthdr == NEXTHDR_IPV6) {
+		if (hdr->nexthdr == NEXTHDR_IPV6 || hdr->nexthdr == NEXTHDR_IPV4) {
 			int offset = (hdr->hdrlen + 1) << 3;
 
 			skb_postpull_rcsum(skb, skb_network_header(skb),
@@ -397,7 +397,8 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
 			skb_reset_network_header(skb);
 			skb_reset_transport_header(skb);
 			skb->encapsulation = 0;
-
+			if (hdr->nexthdr == NEXTHDR_IPV4)
+				skb->protocol = htons(ETH_P_IP);
 			__skb_tunnel_rx(skb, skb->dev, net);
 
 			netif_rx(skb);
-- 
2.29.2


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

* [PATCH net-next 2/2] seg6: ignore routing header with segments left equal to 0
  2021-03-11 15:53 [PATCH net-next 0/2] SRv6: SRH processing improvements Julien Massonneau
  2021-03-11 15:53 ` [PATCH net-next 1/2] seg6: add support for IPv4 decapsulation in ipv6_srh_rcv() Julien Massonneau
@ 2021-03-11 15:53 ` Julien Massonneau
  2021-03-12  0:30 ` [PATCH net-next 0/2] SRv6: SRH processing improvements patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Julien Massonneau @ 2021-03-11 15:53 UTC (permalink / raw)
  To: davem, dsahern, kuba, netdev, dlebrun; +Cc: Julien Massonneau

When there are 2 segments routing header, after an End.B6 action
for example, the second SRH will never be handled by an action, packet will
be dropped when the first SRH has segments left equal to 0.
For actions that doesn't perform decapsulation (currently: End, End.X,
End.T, End.B6, End.B6.Encaps), this patch adds the IP6_FH_F_SKIP_RH flag
in arguments for ipv6_find_hdr().

Signed-off-by: Julien Massonneau <julien.massonneau@6wind.com>
---
 net/ipv6/seg6_local.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index c2a0c78e84d4..8936f48570fc 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -119,12 +119,12 @@ static struct seg6_local_lwt *seg6_local_lwtunnel(struct lwtunnel_state *lwt)
 	return (struct seg6_local_lwt *)lwt->data;
 }
 
-static struct ipv6_sr_hdr *get_srh(struct sk_buff *skb)
+static struct ipv6_sr_hdr *get_srh(struct sk_buff *skb, int flags)
 {
 	struct ipv6_sr_hdr *srh;
 	int len, srhoff = 0;
 
-	if (ipv6_find_hdr(skb, &srhoff, IPPROTO_ROUTING, NULL, NULL) < 0)
+	if (ipv6_find_hdr(skb, &srhoff, IPPROTO_ROUTING, NULL, &flags) < 0)
 		return NULL;
 
 	if (!pskb_may_pull(skb, srhoff + sizeof(*srh)))
@@ -152,13 +152,10 @@ static struct ipv6_sr_hdr *get_and_validate_srh(struct sk_buff *skb)
 {
 	struct ipv6_sr_hdr *srh;
 
-	srh = get_srh(skb);
+	srh = get_srh(skb, IP6_FH_F_SKIP_RH);
 	if (!srh)
 		return NULL;
 
-	if (srh->segments_left == 0)
-		return NULL;
-
 #ifdef CONFIG_IPV6_SEG6_HMAC
 	if (!seg6_hmac_validate_skb(skb))
 		return NULL;
@@ -172,7 +169,7 @@ static bool decap_and_validate(struct sk_buff *skb, int proto)
 	struct ipv6_sr_hdr *srh;
 	unsigned int off = 0;
 
-	srh = get_srh(skb);
+	srh = get_srh(skb, 0);
 	if (srh && srh->segments_left > 0)
 		return false;
 
-- 
2.29.2


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

* Re: [PATCH net-next 0/2] SRv6: SRH processing improvements
  2021-03-11 15:53 [PATCH net-next 0/2] SRv6: SRH processing improvements Julien Massonneau
  2021-03-11 15:53 ` [PATCH net-next 1/2] seg6: add support for IPv4 decapsulation in ipv6_srh_rcv() Julien Massonneau
  2021-03-11 15:53 ` [PATCH net-next 2/2] seg6: ignore routing header with segments left equal to 0 Julien Massonneau
@ 2021-03-12  0:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-12  0:30 UTC (permalink / raw)
  To: Julien Massonneau; +Cc: davem, dsahern, kuba, netdev, dlebrun

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Thu, 11 Mar 2021 16:53:17 +0100 you wrote:
> Add support for IPv4 decapsulation in ipv6_srh_rcv() and
> ignore routing header with segments left equal to 0 for
> seg6local actions that doesn't perfom decapsulation.
> 
> Julien Massonneau (2):
>   seg6: add support for IPv4 decapsulation in ipv6_srh_rcv()
>   seg6: ignore routing header with segments left equal to 0
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] seg6: add support for IPv4 decapsulation in ipv6_srh_rcv()
    https://git.kernel.org/netdev/net-next/c/ee90c6ba341f
  - [net-next,2/2] seg6: ignore routing header with segments left equal to 0
    https://git.kernel.org/netdev/net-next/c/fbbc5bc2ab8c

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-03-12  0:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 15:53 [PATCH net-next 0/2] SRv6: SRH processing improvements Julien Massonneau
2021-03-11 15:53 ` [PATCH net-next 1/2] seg6: add support for IPv4 decapsulation in ipv6_srh_rcv() Julien Massonneau
2021-03-11 15:53 ` [PATCH net-next 2/2] seg6: ignore routing header with segments left equal to 0 Julien Massonneau
2021-03-12  0:30 ` [PATCH net-next 0/2] SRv6: SRH processing improvements patchwork-bot+netdevbpf

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.