summaryrefslogtreecommitdiff
path: root/net/ipv6/esp6.c
diff options
context:
space:
mode:
authorSteffen Klassert <steffen.klassert@secunet.com>2017-01-17 12:23:08 +0300
committerSteffen Klassert <steffen.klassert@secunet.com>2017-01-17 12:23:08 +0300
commiteb758c8864d49f5786432ce38fd8a72bdbbd10cf (patch)
tree1ca9170765259d1cfff4def7f51bc788b42508c7 /net/ipv6/esp6.c
parent03e2a30f6a27e2f3e5283b777f6ddd146b38c738 (diff)
downloadlinux-eb758c8864d49f5786432ce38fd8a72bdbbd10cf.tar.xz
esp: Introduce a helper to setup the trailer
We need to setup the trailer in two different cases, so add a helper to avoid code duplication. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/ipv6/esp6.c')
-rw-r--r--net/ipv6/esp6.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index a428ac6b7c74..ff54faa75631 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -198,6 +198,22 @@ static void esp_output_done_esn(struct crypto_async_request *base, int err)
esp_output_done(base, err);
}
+static void esp_output_fill_trailer(u8 *tail, int tfclen, int plen, __u8 proto)
+{
+ /* Fill padding... */
+ if (tfclen) {
+ memset(tail, 0, tfclen);
+ tail += tfclen;
+ }
+ do {
+ int i;
+ for (i = 0; i < plen - 2; i++)
+ tail[i] = i + 1;
+ } while (0);
+ tail[plen - 2] = plen - 2;
+ tail[plen - 1] = proto;
+}
+
static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
{
int err;
@@ -284,18 +300,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
tail = vaddr + pfrag->offset;
- /* Fill padding... */
- if (tfclen) {
- memset(tail, 0, tfclen);
- tail += tfclen;
- }
- do {
- int i;
- for (i = 0; i < plen - 2; i++)
- tail[i] = i + 1;
- } while (0);
- tail[plen - 2] = plen - 2;
- tail[plen - 1] = proto;
+ esp_output_fill_trailer(tail, tfclen, plen, proto);
kunmap_atomic(vaddr);
@@ -375,20 +380,9 @@ cow:
esph = ip_esp_hdr(skb);
skip_cow:
- /* Fill padding... */
- if (tfclen) {
- memset(tail, 0, tfclen);
- tail += tfclen;
- }
- do {
- int i;
- for (i = 0; i < plen - 2; i++)
- tail[i] = i + 1;
- } while (0);
- tail[plen - 2] = plen - 2;
- tail[plen - 1] = proto;
- pskb_put(skb, trailer, clen - skb->len + alen);
+ esp_output_fill_trailer(tail, tfclen, plen, proto);
+ pskb_put(skb, trailer, clen - skb->len + alen);
skb_push(skb, -skb_network_offset(skb));
esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);