netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ahmed Abdelsalam <amsalam20@gmail.com>
To: davem@davemloft.net, david.lebrun@uclouvain.be
Cc: amsalam20@gmail.com, netdev@vger.kernel.org
Subject: [PATCH] ipv6: sr: update the struct ipv6_sr_hdr
Date: Sun, 12 Nov 2017 21:37:01 +0100	[thread overview]
Message-ID: <1510519021-1275-1-git-send-email-amsalam20@gmail.com> (raw)

The IPv6 Segment Routing Header (SRH) format has been updated srating 
from revision 6 of the SRH ietf draft. The update includes the following 
SRH fields

(1) The "First Segment" field changed to be "Last Entry" which contains 
the index, in the Segment List, of the last element of the Segment List.

(2) The 16 bit "reserved" field now is used as a "tag" which tags a packet
as part of a class or group of packets, e.g.,packets sharing the same
set of properties.

This patch updates the struct ipv6_sr_hdr, so it complies with the updated
SRH draft. It also update the different parts of the kernel that were 
using the old fields names.

Signed-off-by: Ahmed Abdelsalam <amsalam20@gmail.com>
---
 This patch is tested by re-compiling the whole kernel after the changes.

 include/uapi/linux/seg6.h |  4 ++--
 net/ipv6/exthdrs.c        |  2 +-
 net/ipv6/seg6.c           |  4 ++--
 net/ipv6/seg6_hmac.c      | 14 +++++++-------
 net/ipv6/seg6_iptunnel.c  |  4 ++--
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h
index 2f6fb0d..3f4b3ab 100644
--- a/include/uapi/linux/seg6.h
+++ b/include/uapi/linux/seg6.h
@@ -26,9 +26,9 @@ struct ipv6_sr_hdr {
 	__u8	hdrlen;
 	__u8	type;
 	__u8	segments_left;
-	__u8	first_segment;
+	__u8	last_entry;
 	__u8	flags;
-	__u16	reserved;
+	__u16	tag;
 
 	struct in6_addr segments[0];
 };
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 83bd757..d53af71 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -918,7 +918,7 @@ static void ipv6_push_rthdr4(struct sk_buff *skb, u8 *proto,
 	sr_phdr = skb_push(skb, plen);
 	memcpy(sr_phdr, sr_ihdr, sizeof(struct ipv6_sr_hdr));
 
-	hops = sr_ihdr->first_segment + 1;
+	hops = sr_ihdr->last_entry + 1;
 	memcpy(sr_phdr->segments + 1, sr_ihdr->segments + 1,
 	       (hops - 1) * sizeof(struct in6_addr));
 
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index c814077..3d5279d 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -40,10 +40,10 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len)
 	if (((srh->hdrlen + 1) << 3) != len)
 		return false;
 
-	if (srh->segments_left > srh->first_segment)
+	if (srh->segments_left > srh->last_entry)
 		return false;
 
-	tlv_offset = sizeof(*srh) + ((srh->first_segment + 1) << 4);
+	tlv_offset = sizeof(*srh) + ((srh->last_entry + 1) << 4);
 
 	trailing = len - tlv_offset;
 	if (trailing < 0)
diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
index 33fb35c..5107ebb 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -91,7 +91,7 @@ static struct sr6_tlv_hmac *seg6_get_tlv_hmac(struct ipv6_sr_hdr *srh)
 {
 	struct sr6_tlv_hmac *tlv;
 
-	if (srh->hdrlen < (srh->first_segment + 1) * 2 + 5)
+	if (srh->hdrlen < (srh->last_entry + 1) * 2 + 5)
 		return NULL;
 
 	if (!sr_has_hmac(srh))
@@ -175,8 +175,8 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
 	 * hash function (RadioGatun) with up to 1216 bits
 	 */
 
-	/* saddr(16) + first_seg(1) + flags(1) + keyid(4) + seglist(16n) */
-	plen = 16 + 1 + 1 + 4 + (hdr->first_segment + 1) * 16;
+	/* saddr(16) + last_entry(1) + flags(1) + keyid(4) + seglist(16n) */
+	plen = 16 + 1 + 1 + 4 + (hdr->last_entry + 1) * 16;
 
 	/* this limit allows for 14 segments */
 	if (plen >= SEG6_HMAC_RING_SIZE)
@@ -186,7 +186,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
 	 * as follows, in order:
 	 *
 	 * 1. Source IPv6 address (128 bits)
-	 * 2. first_segment value (8 bits)
+	 * 2. last_entry value (8 bits)
 	 * 3. Flags (8 bits)
 	 * 4. HMAC Key ID (32 bits)
 	 * 5. All segments in the segments list (n * 128 bits)
@@ -200,8 +200,8 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
 	memcpy(off, saddr, 16);
 	off += 16;
 
-	/* first_segment value */
-	*off++ = hdr->first_segment;
+	/* last_entry value */
+	*off++ = hdr->last_entry;
 
 	/* flags */
 	*off++ = hdr->flags;
@@ -211,7 +211,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
 	off += 4;
 
 	/* all segments in the list */
-	for (i = 0; i < hdr->first_segment + 1; i++) {
+	for (i = 0; i < hdr->last_entry + 1; i++) {
 		memcpy(off, hdr->segments + i, 16);
 		off += 16;
 	}
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index bd6cc68..fc9813e 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -133,7 +133,7 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto)
 
 	isrh->nexthdr = proto;
 
-	hdr->daddr = isrh->segments[isrh->first_segment];
+	hdr->daddr = isrh->segments[isrh->last_entry];
 	set_tun_src(net, skb->dev, &hdr->daddr, &hdr->saddr);
 
 #ifdef CONFIG_IPV6_SEG6_HMAC
@@ -184,7 +184,7 @@ int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh)
 	hdr->nexthdr = NEXTHDR_ROUTING;
 
 	isrh->segments[0] = hdr->daddr;
-	hdr->daddr = isrh->segments[isrh->first_segment];
+	hdr->daddr = isrh->segments[isrh->last_entry];
 
 #ifdef CONFIG_IPV6_SEG6_HMAC
 	if (sr_has_hmac(isrh)) {
-- 
2.1.4

             reply	other threads:[~2017-11-12 20:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-12 20:37 Ahmed Abdelsalam [this message]
2017-11-14 12:37 ` [PATCH] ipv6: sr: update the struct ipv6_sr_hdr David Miller
2017-11-14 14:14   ` Edward Cree
2017-11-14 14:31     ` Ahmed Abdelsalam
2017-11-15  0:55       ` David Miller
2017-11-15 11:42         ` Ahmed Abdelsalam
2017-11-15 13:37           ` David Miller
2017-11-15  0:54     ` David Miller

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=1510519021-1275-1-git-send-email-amsalam20@gmail.com \
    --to=amsalam20@gmail.com \
    --cc=davem@davemloft.net \
    --cc=david.lebrun@uclouvain.be \
    --cc=netdev@vger.kernel.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 NNTP newsgroup(s).