From: David Lebrun <david.lebrun@uclouvain.be>
To: <netdev@vger.kernel.org>
Cc: David Lebrun <david.lebrun@uclouvain.be>
Subject: [PATCH net-next v4 6/9] ipv6: sr: add calls to verify and insert HMAC signatures
Date: Fri, 4 Nov 2016 11:32:20 +0100 [thread overview]
Message-ID: <1478255543-32588-2-git-send-email-david.lebrun@uclouvain.be> (raw)
In-Reply-To: <1478255388-32213-1-git-send-email-david.lebrun@uclouvain.be>
This patch enables the verification of the HMAC signature for transiting
SR-enabled packets, and its insertion on encapsulated/injected SRH.
Signed-off-by: David Lebrun <david.lebrun@uclouvain.be>
---
net/ipv6/exthdrs.c | 10 ++++++++++
net/ipv6/seg6_iptunnel.c | 21 +++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 21a86cf..973a128e 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -49,6 +49,9 @@
#endif
#include <linux/seg6.h>
#include <net/seg6.h>
+#ifdef CONFIG_IPV6_SEG6_HMAC
+#include <net/seg6_hmac.h>
+#endif
#include <linux/uaccess.h>
@@ -340,6 +343,13 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
return -1;
}
+#ifdef CONFIG_IPV6_SEG6_HMAC
+ if (!seg6_hmac_validate_skb(skb)) {
+ kfree_skb(skb);
+ return -1;
+ }
+#endif
+
looped_back:
if (hdr->segments_left > 0) {
if (hdr->nexthdr != NEXTHDR_IPV6 && hdr->segments_left == 1 &&
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 9abeb45..4a3f1ba 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -29,6 +29,9 @@
#ifdef CONFIG_DST_CACHE
#include <net/dst_cache.h>
#endif
+#ifdef CONFIG_IPV6_SEG6_HMAC
+#include <net/seg6_hmac.h>
+#endif
struct seg6_lwt {
#ifdef CONFIG_DST_CACHE
@@ -130,6 +133,14 @@ static int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh)
hdr->daddr = isrh->segments[isrh->first_segment];
set_tun_src(net, skb->dev, &hdr->daddr, &hdr->saddr);
+#ifdef CONFIG_IPV6_SEG6_HMAC
+ if (sr_has_hmac(isrh)) {
+ err = seg6_push_hmac(net, &hdr->saddr, isrh);
+ if (unlikely(err))
+ return err;
+ }
+#endif
+
skb_postpush_rcsum(skb, hdr, tot_len);
return 0;
@@ -171,6 +182,16 @@ static int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh)
isrh->segments[0] = hdr->daddr;
hdr->daddr = isrh->segments[isrh->first_segment];
+#ifdef CONFIG_IPV6_SEG6_HMAC
+ if (sr_has_hmac(isrh)) {
+ struct net *net = dev_net(skb_dst(skb)->dev);
+
+ err = seg6_push_hmac(net, &hdr->saddr, isrh);
+ if (unlikely(err))
+ return err;
+ }
+#endif
+
skb_postpush_rcsum(skb, hdr, sizeof(struct ipv6hdr) + hdrlen);
return 0;
--
2.7.3
next prev parent reply other threads:[~2016-11-04 10:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-04 10:29 [PATCH net-next v4 0/9] net: add support for IPv6 Segment Routing David Lebrun
2016-11-04 10:29 ` [PATCH net-next v4 1/9] ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header) David Lebrun
2016-11-04 10:29 ` [PATCH net-next v4 2/9] ipv6: sr: add code base for control plane support of SR-IPv6 David Lebrun
2016-11-04 10:29 ` [PATCH net-next v4 3/9] ipv6: sr: add support for SRH encapsulation and injection with lwtunnels David Lebrun
2016-11-04 14:21 ` Thomas Graf
2016-11-04 16:26 ` Tom Herbert
2016-11-06 14:02 ` David Lebrun
2016-11-07 2:42 ` [lkp] [ipv6] 3e1ad8cb8a: kmsg.IPv6:Attempt_to_unregister_permanent_protocol kernel test robot
2016-11-04 10:29 ` [PATCH net-next v4 4/9] ipv6: sr: add core files for SR HMAC support David Lebrun
2016-11-04 10:32 ` [PATCH net-next v4 5/9] ipv6: sr: implement API to control SR HMAC structure David Lebrun
2016-11-04 10:32 ` David Lebrun [this message]
2016-11-04 10:32 ` [PATCH net-next v4 7/9] ipv6: add source address argument for ipv6_push_nfrag_opts David Lebrun
2016-11-04 10:32 ` [PATCH net-next v4 8/9] ipv6: sr: add support for SRH injection through setsockopt David Lebrun
2016-11-04 10:32 ` [PATCH net-next v4 9/9] ipv6: sr: add documentation file for per-interface sysctls David Lebrun
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=1478255543-32588-2-git-send-email-david.lebrun@uclouvain.be \
--to=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).