From: Tom Herbert <tom@herbertland.com>
To: davem@davemloft.net, netdev@vger.kernel.org, dlebrun@google.com,
ahabdels.dev@gmail.com
Cc: Tom Herbert <tom@quantonium.net>
Subject: [RFC PATCH 4/6] ah6: Create function __zero_out_mutable_opts
Date: Fri, 31 May 2019 09:48:38 -0700 [thread overview]
Message-ID: <1559321320-9444-5-git-send-email-tom@quantonium.net> (raw)
In-Reply-To: <1559321320-9444-1-git-send-email-tom@quantonium.net>
This is an adaptation of zero_out_mutable_opts that takes three
additional arguments: offset of the TLVs, a mask to locate the
mutable bit in the TLV type, and the type value for single byte
padding.
zero_out_mutable_opts calls the new function and sets the arguments
appropriate to Hop-by-Hop and Destination Options. The function will
be used to support zeroing out mutable SRH TLVs' data with the
appropriate arguments for SRH TLVs.
Signed-off-by: Tom Herbert <tom@quantonium.net>
---
net/ipv6/ah6.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 68b9e92..1e80157 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -102,32 +102,28 @@ static inline struct scatterlist *ah_req_sg(struct crypto_ahash *ahash,
__alignof__(struct scatterlist));
}
-static bool zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
+static bool __zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr, int off,
+ unsigned char mut_bit, unsigned char pad1)
{
u8 *opt = (u8 *)opthdr;
int len = ipv6_optlen(opthdr);
- int off = 0;
int optlen = 0;
- off += 2;
- len -= 2;
+ len -= off;
while (len > 0) {
-
- switch (opt[off]) {
-
- case IPV6_TLV_PAD1:
+ if (opt[off] == pad1) {
optlen = 1;
- break;
- default:
+ } else {
if (len < 2)
goto bad;
- optlen = opt[off+1]+2;
+
+ optlen = opt[off + 1] + 2;
if (len < optlen)
goto bad;
- if (opt[off] & 0x20)
- memset(&opt[off+2], 0, opt[off+1]);
- break;
+
+ if (opt[off] & mut_bit)
+ memset(&opt[off + 2], 0, opt[off + 1]);
}
off += optlen;
@@ -140,6 +136,11 @@ static bool zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
return false;
}
+static bool zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
+{
+ return __zero_out_mutable_opts(opthdr, 2, 0x20, IPV6_TLV_PAD1);
+}
+
#if IS_ENABLED(CONFIG_IPV6_MIP6)
/**
* ipv6_rearrange_destopt - rearrange IPv6 destination options header
--
2.7.4
next prev parent reply other threads:[~2019-05-31 16:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 16:48 [RFC PATCH 0/6] seg6: Segment routing fixes Tom Herbert
2019-05-31 16:48 ` [RFC PATCH 1/6] seg6: Fix TLV definitions Tom Herbert
2019-05-31 16:48 ` [RFC PATCH 2/6] seg6: Implement a TLV parsing loop Tom Herbert
2019-05-31 16:48 ` [RFC PATCH 3/6] seg6: Obsolete unused SRH flags Tom Herbert
2019-05-31 16:48 ` Tom Herbert [this message]
2019-05-31 16:48 ` [RFC PATCH 5/6] ah6: Be explicit about which routing types are processed Tom Herbert
2019-05-31 16:48 ` [RFC PATCH 6/6] seg6: Add support to rearrange SRH for AH ICV calculation Tom Herbert
2019-05-31 17:07 ` Ahmed Abdelsalam
2019-05-31 17:34 ` Tom Herbert
2019-06-02 9:54 ` Ahmed Abdelsalam
2019-06-02 15:48 ` Tom Herbert
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=1559321320-9444-5-git-send-email-tom@quantonium.net \
--to=tom@herbertland.com \
--cc=ahabdels.dev@gmail.com \
--cc=davem@davemloft.net \
--cc=dlebrun@google.com \
--cc=netdev@vger.kernel.org \
--cc=tom@quantonium.net \
/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).