2007-10-09 07:16:30 +07:00
|
|
|
/*
|
|
|
|
* xfrm_output.c - Common IPsec encapsulation code.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netdevice.h>
|
2007-11-14 12:43:11 +07:00
|
|
|
#include <linux/netfilter.h>
|
2007-10-09 07:16:30 +07:00
|
|
|
#include <linux/skbuff.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2007-10-09 07:16:30 +07:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <net/dst.h>
|
|
|
|
#include <net/xfrm.h>
|
|
|
|
|
2015-09-16 08:04:18 +07:00
|
|
|
static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb);
|
2007-11-14 12:43:43 +07:00
|
|
|
|
2012-03-22 06:32:39 +07:00
|
|
|
static int xfrm_skb_check_space(struct sk_buff *skb)
|
2007-10-09 07:25:08 +07:00
|
|
|
{
|
2009-06-02 12:19:30 +07:00
|
|
|
struct dst_entry *dst = skb_dst(skb);
|
2007-11-14 12:33:01 +07:00
|
|
|
int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev)
|
2007-10-09 07:25:08 +07:00
|
|
|
- skb_headroom(skb);
|
2008-05-13 10:48:31 +07:00
|
|
|
int ntail = dst->dev->needed_tailroom - skb_tailroom(skb);
|
2007-10-09 07:25:08 +07:00
|
|
|
|
2008-09-30 16:03:19 +07:00
|
|
|
if (nhead <= 0) {
|
|
|
|
if (ntail <= 0)
|
|
|
|
return 0;
|
|
|
|
nhead = 0;
|
|
|
|
} else if (ntail < 0)
|
|
|
|
ntail = 0;
|
|
|
|
|
|
|
|
return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC);
|
2007-10-09 07:25:08 +07:00
|
|
|
}
|
|
|
|
|
2015-05-12 17:29:44 +07:00
|
|
|
/* Children define the path of the packet through the
|
|
|
|
* Linux networking. Thus, destinations are stackable.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct dst_entry *skb_dst_pop(struct sk_buff *skb)
|
|
|
|
{
|
2017-11-29 03:40:22 +07:00
|
|
|
struct dst_entry *child = dst_clone(xfrm_dst_child(skb_dst(skb)));
|
2015-05-12 17:29:44 +07:00
|
|
|
|
|
|
|
skb_dst_drop(skb);
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
2007-11-14 12:43:43 +07:00
|
|
|
static int xfrm_output_one(struct sk_buff *skb, int err)
|
2007-10-09 07:16:30 +07:00
|
|
|
{
|
2009-06-02 12:19:30 +07:00
|
|
|
struct dst_entry *dst = skb_dst(skb);
|
2007-10-09 07:16:30 +07:00
|
|
|
struct xfrm_state *x = dst->xfrm;
|
2008-11-26 08:38:20 +07:00
|
|
|
struct net *net = xs_net(x);
|
2007-10-09 07:16:30 +07:00
|
|
|
|
2007-11-14 12:43:43 +07:00
|
|
|
if (err <= 0)
|
|
|
|
goto resume;
|
2007-10-09 07:16:30 +07:00
|
|
|
|
|
|
|
do {
|
2012-03-22 06:32:39 +07:00
|
|
|
err = xfrm_skb_check_space(skb);
|
2007-12-25 07:00:09 +07:00
|
|
|
if (err) {
|
2008-11-26 08:59:52 +07:00
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
|
2007-12-19 13:14:25 +07:00
|
|
|
goto error_nolock;
|
2007-12-25 07:00:09 +07:00
|
|
|
}
|
2007-12-19 13:14:25 +07:00
|
|
|
|
2018-06-12 17:44:26 +07:00
|
|
|
skb->mark = xfrm_smark_get(skb->mark, x);
|
net: xfrm: support setting an output mark.
On systems that use mark-based routing it may be necessary for
routing lookups to use marks in order for packets to be routed
correctly. An example of such a system is Android, which uses
socket marks to route packets via different networks.
Currently, routing lookups in tunnel mode always use a mark of
zero, making routing incorrect on such systems.
This patch adds a new output_mark element to the xfrm state and
a corresponding XFRMA_OUTPUT_MARK netlink attribute. The output
mark differs from the existing xfrm mark in two ways:
1. The xfrm mark is used to match xfrm policies and states, while
the xfrm output mark is used to set the mark (and influence
the routing) of the packets emitted by those states.
2. The existing mark is constrained to be a subset of the bits of
the originating socket or transformed packet, but the output
mark is arbitrary and depends only on the state.
The use of a separate mark provides additional flexibility. For
example:
- A packet subject to two transforms (e.g., transport mode inside
tunnel mode) can have two different output marks applied to it,
one for the transport mode SA and one for the tunnel mode SA.
- On a system where socket marks determine routing, the packets
emitted by an IPsec tunnel can be routed based on a mark that
is determined by the tunnel, not by the marks of the
unencrypted packets.
- Support for setting the output marks can be introduced without
breaking any existing setups that employ both mark-based
routing and xfrm tunnel mode. Simply changing the code to use
the xfrm mark for routing output packets could xfrm mark could
change behaviour in a way that breaks these setups.
If the output mark is unspecified or set to zero, the mark is not
set or changed.
Tested: make allyesconfig; make -j64
Tested: https://android-review.googlesource.com/452776
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
2017-08-11 00:11:33 +07:00
|
|
|
|
2007-11-14 12:39:38 +07:00
|
|
|
err = x->outer_mode->output(x, skb);
|
2007-12-25 07:00:09 +07:00
|
|
|
if (err) {
|
2008-11-26 08:59:52 +07:00
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEMODEERROR);
|
2007-12-19 13:14:25 +07:00
|
|
|
goto error_nolock;
|
2007-12-25 07:00:09 +07:00
|
|
|
}
|
2007-11-14 12:39:38 +07:00
|
|
|
|
2007-10-09 07:16:30 +07:00
|
|
|
spin_lock_bh(&x->lock);
|
2012-12-28 15:06:28 +07:00
|
|
|
|
|
|
|
if (unlikely(x->km.state != XFRM_STATE_VALID)) {
|
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEINVALID);
|
2013-05-22 08:40:47 +07:00
|
|
|
err = -EINVAL;
|
2013-02-01 12:17:16 +07:00
|
|
|
goto error;
|
2012-12-28 15:06:28 +07:00
|
|
|
}
|
|
|
|
|
2007-12-19 13:14:25 +07:00
|
|
|
err = xfrm_state_check_expire(x);
|
2007-12-25 07:00:09 +07:00
|
|
|
if (err) {
|
2008-11-26 08:59:52 +07:00
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEEXPIRED);
|
2007-10-09 07:16:30 +07:00
|
|
|
goto error;
|
2007-12-25 07:00:09 +07:00
|
|
|
}
|
2007-10-09 07:16:30 +07:00
|
|
|
|
2011-03-08 07:08:32 +07:00
|
|
|
err = x->repl->overflow(x, skb);
|
|
|
|
if (err) {
|
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATESEQERROR);
|
|
|
|
goto error;
|
2007-10-09 07:25:53 +07:00
|
|
|
}
|
|
|
|
|
2007-10-09 07:16:30 +07:00
|
|
|
x->curlft.bytes += skb->len;
|
|
|
|
x->curlft.packets++;
|
|
|
|
|
|
|
|
spin_unlock_bh(&x->lock);
|
|
|
|
|
2011-03-16 04:08:28 +07:00
|
|
|
skb_dst_force(skb);
|
2018-09-11 15:31:15 +07:00
|
|
|
if (!skb_dst(skb)) {
|
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
|
|
|
|
goto error_nolock;
|
|
|
|
}
|
2011-03-16 04:08:28 +07:00
|
|
|
|
2017-04-14 15:06:10 +07:00
|
|
|
if (xfrm_offload(skb)) {
|
|
|
|
x->type_offload->encap(x, skb);
|
|
|
|
} else {
|
2017-10-30 16:04:04 +07:00
|
|
|
/* Inner headers are invalid now. */
|
|
|
|
skb->encapsulation = 0;
|
|
|
|
|
2017-04-14 15:06:10 +07:00
|
|
|
err = x->type->output(x, skb);
|
|
|
|
if (err == -EINPROGRESS)
|
|
|
|
goto out;
|
|
|
|
}
|
2007-11-14 12:43:43 +07:00
|
|
|
|
|
|
|
resume:
|
2007-12-21 11:43:36 +07:00
|
|
|
if (err) {
|
2008-11-26 08:59:52 +07:00
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEPROTOERROR);
|
2007-10-10 03:33:35 +07:00
|
|
|
goto error_nolock;
|
2007-12-21 11:43:36 +07:00
|
|
|
}
|
2007-10-10 03:33:35 +07:00
|
|
|
|
2010-06-04 08:57:38 +07:00
|
|
|
dst = skb_dst_pop(skb);
|
2009-06-02 12:19:30 +07:00
|
|
|
if (!dst) {
|
2008-11-26 08:59:52 +07:00
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
|
2007-10-09 07:16:30 +07:00
|
|
|
err = -EHOSTUNREACH;
|
|
|
|
goto error_nolock;
|
|
|
|
}
|
2011-03-16 04:09:32 +07:00
|
|
|
skb_dst_set(skb, dst);
|
2007-10-09 07:16:30 +07:00
|
|
|
x = dst->xfrm;
|
2007-10-18 11:35:51 +07:00
|
|
|
} while (x && !(x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL));
|
2007-10-09 07:16:30 +07:00
|
|
|
|
2013-06-01 23:23:15 +07:00
|
|
|
return 0;
|
2007-10-09 07:16:30 +07:00
|
|
|
|
|
|
|
error:
|
|
|
|
spin_unlock_bh(&x->lock);
|
2007-11-14 12:43:11 +07:00
|
|
|
error_nolock:
|
|
|
|
kfree_skb(skb);
|
2013-06-01 23:23:15 +07:00
|
|
|
out:
|
|
|
|
return err;
|
2007-11-14 12:43:11 +07:00
|
|
|
}
|
|
|
|
|
2007-11-14 12:43:43 +07:00
|
|
|
int xfrm_output_resume(struct sk_buff *skb, int err)
|
2007-11-14 12:43:11 +07:00
|
|
|
{
|
2015-09-16 08:04:16 +07:00
|
|
|
struct net *net = xs_net(skb_dst(skb)->xfrm);
|
2015-09-18 05:21:31 +07:00
|
|
|
|
2007-11-14 12:43:43 +07:00
|
|
|
while (likely((err = xfrm_output_one(skb, err)) == 0)) {
|
2007-11-14 12:43:11 +07:00
|
|
|
nf_reset(skb);
|
|
|
|
|
2015-10-08 04:48:45 +07:00
|
|
|
err = skb_dst(skb)->ops->local_out(net, skb->sk, skb);
|
2007-11-14 12:43:11 +07:00
|
|
|
if (unlikely(err != 1))
|
2007-11-14 12:43:43 +07:00
|
|
|
goto out;
|
2007-11-14 12:43:11 +07:00
|
|
|
|
2009-06-02 12:19:30 +07:00
|
|
|
if (!skb_dst(skb)->xfrm)
|
2015-10-08 04:48:35 +07:00
|
|
|
return dst_output(net, skb->sk, skb);
|
2007-11-14 12:43:11 +07:00
|
|
|
|
2009-06-02 12:19:30 +07:00
|
|
|
err = nf_hook(skb_dst(skb)->ops->family,
|
2015-09-16 08:04:16 +07:00
|
|
|
NF_INET_POST_ROUTING, net, skb->sk, skb,
|
2009-06-02 12:19:30 +07:00
|
|
|
NULL, skb_dst(skb)->dev, xfrm_output2);
|
2007-11-14 12:43:11 +07:00
|
|
|
if (unlikely(err != 1))
|
2007-11-14 12:43:43 +07:00
|
|
|
goto out;
|
2007-11-14 12:43:11 +07:00
|
|
|
}
|
|
|
|
|
2007-11-14 12:43:43 +07:00
|
|
|
if (err == -EINPROGRESS)
|
|
|
|
err = 0;
|
|
|
|
|
|
|
|
out:
|
2007-11-14 12:43:11 +07:00
|
|
|
return err;
|
|
|
|
}
|
2007-11-14 12:43:43 +07:00
|
|
|
EXPORT_SYMBOL_GPL(xfrm_output_resume);
|
2007-11-14 12:43:11 +07:00
|
|
|
|
2015-09-16 08:04:18 +07:00
|
|
|
static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb)
|
2007-11-14 12:43:11 +07:00
|
|
|
{
|
2007-11-14 12:43:43 +07:00
|
|
|
return xfrm_output_resume(skb, 1);
|
|
|
|
}
|
2007-11-14 12:43:11 +07:00
|
|
|
|
2015-09-16 08:04:18 +07:00
|
|
|
static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb)
|
2007-11-14 12:43:43 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *segs;
|
2007-11-14 12:43:11 +07:00
|
|
|
|
2016-01-08 19:21:46 +07:00
|
|
|
BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET);
|
|
|
|
BUILD_BUG_ON(sizeof(*IP6CB(skb)) > SKB_SGO_CB_OFFSET);
|
2007-11-14 12:43:11 +07:00
|
|
|
segs = skb_gso_segment(skb, 0);
|
|
|
|
kfree_skb(skb);
|
2008-04-29 15:03:09 +07:00
|
|
|
if (IS_ERR(segs))
|
2007-11-14 12:43:11 +07:00
|
|
|
return PTR_ERR(segs);
|
2014-10-20 18:49:17 +07:00
|
|
|
if (segs == NULL)
|
|
|
|
return -EINVAL;
|
2007-11-14 12:43:11 +07:00
|
|
|
|
|
|
|
do {
|
|
|
|
struct sk_buff *nskb = segs->next;
|
|
|
|
int err;
|
|
|
|
|
2018-07-30 10:42:53 +07:00
|
|
|
skb_mark_not_on_list(segs);
|
2015-09-16 08:04:18 +07:00
|
|
|
err = xfrm_output2(net, sk, segs);
|
2007-11-14 12:43:11 +07:00
|
|
|
|
|
|
|
if (unlikely(err)) {
|
2014-09-10 06:08:46 +07:00
|
|
|
kfree_skb_list(nskb);
|
2007-11-14 12:43:11 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
segs = nskb;
|
|
|
|
} while (segs);
|
|
|
|
|
|
|
|
return 0;
|
2007-10-09 07:16:30 +07:00
|
|
|
}
|
2007-11-14 12:43:43 +07:00
|
|
|
|
2015-04-06 09:19:04 +07:00
|
|
|
int xfrm_output(struct sock *sk, struct sk_buff *skb)
|
2007-11-14 12:43:43 +07:00
|
|
|
{
|
2009-06-02 12:19:30 +07:00
|
|
|
struct net *net = dev_net(skb_dst(skb)->dev);
|
2017-04-14 15:06:10 +07:00
|
|
|
struct xfrm_state *x = skb_dst(skb)->xfrm;
|
2007-11-14 12:43:43 +07:00
|
|
|
int err;
|
|
|
|
|
2017-04-14 15:06:10 +07:00
|
|
|
secpath_reset(skb);
|
|
|
|
|
|
|
|
if (xfrm_dev_offload_ok(skb, x)) {
|
|
|
|
struct sec_path *sp;
|
|
|
|
|
|
|
|
sp = secpath_dup(skb->sp);
|
|
|
|
if (!sp) {
|
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
|
|
|
|
kfree_skb(skb);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
if (skb->sp)
|
|
|
|
secpath_put(skb->sp);
|
|
|
|
skb->sp = sp;
|
2017-04-14 15:07:39 +07:00
|
|
|
skb->encapsulation = 1;
|
2017-04-14 15:06:10 +07:00
|
|
|
|
|
|
|
sp->olen++;
|
|
|
|
sp->xvec[skb->sp->len++] = x;
|
|
|
|
xfrm_state_hold(x);
|
|
|
|
|
|
|
|
if (skb_is_gso(skb)) {
|
|
|
|
skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
|
|
|
|
|
|
|
|
return xfrm_output2(net, sk, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x->xso.dev && x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-11-14 12:43:43 +07:00
|
|
|
if (skb_is_gso(skb))
|
2015-09-16 08:04:18 +07:00
|
|
|
return xfrm_output_gso(net, sk, skb);
|
2007-11-14 12:43:43 +07:00
|
|
|
|
|
|
|
if (skb->ip_summed == CHECKSUM_PARTIAL) {
|
|
|
|
err = skb_checksum_help(skb);
|
|
|
|
if (err) {
|
2008-11-26 08:59:52 +07:00
|
|
|
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
|
2007-11-14 12:43:43 +07:00
|
|
|
kfree_skb(skb);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-14 15:06:10 +07:00
|
|
|
out:
|
2015-09-16 08:04:18 +07:00
|
|
|
return xfrm_output2(net, sk, skb);
|
2007-11-14 12:43:43 +07:00
|
|
|
}
|
2014-05-13 00:54:34 +07:00
|
|
|
EXPORT_SYMBOL_GPL(xfrm_output);
|
2008-03-25 04:51:51 +07:00
|
|
|
|
|
|
|
int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct xfrm_mode *inner_mode;
|
|
|
|
if (x->sel.family == AF_UNSPEC)
|
|
|
|
inner_mode = xfrm_ip2inner_mode(x,
|
2009-06-02 12:19:30 +07:00
|
|
|
xfrm_af2proto(skb_dst(skb)->ops->family));
|
2008-03-25 04:51:51 +07:00
|
|
|
else
|
|
|
|
inner_mode = x->inner_mode;
|
|
|
|
|
|
|
|
if (inner_mode == NULL)
|
|
|
|
return -EAFNOSUPPORT;
|
|
|
|
return inner_mode->afinfo->extract_output(x, skb);
|
|
|
|
}
|
2014-05-13 00:54:34 +07:00
|
|
|
EXPORT_SYMBOL_GPL(xfrm_inner_extract_output);
|
2008-03-25 04:51:51 +07:00
|
|
|
|
2013-08-14 18:05:23 +07:00
|
|
|
void xfrm_local_error(struct sk_buff *skb, int mtu)
|
|
|
|
{
|
2013-08-18 18:47:01 +07:00
|
|
|
unsigned int proto;
|
2013-08-14 18:05:23 +07:00
|
|
|
struct xfrm_state_afinfo *afinfo;
|
|
|
|
|
2013-08-18 18:47:01 +07:00
|
|
|
if (skb->protocol == htons(ETH_P_IP))
|
|
|
|
proto = AF_INET;
|
|
|
|
else if (skb->protocol == htons(ETH_P_IPV6))
|
|
|
|
proto = AF_INET6;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
afinfo = xfrm_state_get_afinfo(proto);
|
2018-03-16 09:35:51 +07:00
|
|
|
if (afinfo) {
|
2017-01-09 20:20:47 +07:00
|
|
|
afinfo->local_error(skb, mtu);
|
2018-03-16 09:35:51 +07:00
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
2013-08-14 18:05:23 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(xfrm_local_error);
|