xfrm: remove output indirection from xfrm_mode
Same is input indirection. Only exception: we need to export
xfrm_outer_mode_output for pktgen.
Increases size of vmlinux by about 163 byte:
Before:
text data bss dec filename
15730208 6936948 4046908 26714064 vmlinux
After:
15730311 6937008
4046908 26714227 vmlinux
xfrm_inner_extract_output has no more external callers, make it static.
v2: add IS_ENABLED(IPV6) guard in xfrm6_prepare_output
add two missing breaks in xfrm_outer_mode_output (Sabrina Dubroca)
add WARN_ON_ONCE for 'call AF_INET6 related output function, but
CONFIG_IPV6=n' case.
make xfrm_inner_extract_output static
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:

committed by
Steffen Klassert

parent
c2d305e510
commit
0c620e97b3
@@ -105,7 +105,6 @@ out:
|
||||
static struct xfrm_mode xfrm6_beet_mode = {
|
||||
.input2 = xfrm6_beet_input,
|
||||
.output2 = xfrm6_beet_output,
|
||||
.output = xfrm6_prepare_output,
|
||||
.owner = THIS_MODULE,
|
||||
.encap = XFRM_MODE_BEET,
|
||||
.flags = XFRM_MODE_FLAG_TUNNEL,
|
||||
|
@@ -33,35 +33,7 @@
|
||||
#include <net/ipv6.h>
|
||||
#include <net/xfrm.h>
|
||||
|
||||
/* Add route optimization header space.
|
||||
*
|
||||
* The IP header and mutable extension headers will be moved forward to make
|
||||
* space for the route optimization header.
|
||||
*/
|
||||
static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||
{
|
||||
struct ipv6hdr *iph;
|
||||
u8 *prevhdr;
|
||||
int hdr_len;
|
||||
|
||||
iph = ipv6_hdr(skb);
|
||||
|
||||
hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
|
||||
if (hdr_len < 0)
|
||||
return hdr_len;
|
||||
skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
|
||||
skb_set_network_header(skb, -x->props.header_len);
|
||||
skb->transport_header = skb->network_header + hdr_len;
|
||||
__skb_pull(skb, hdr_len);
|
||||
memmove(ipv6_hdr(skb), iph, hdr_len);
|
||||
|
||||
x->lastused = ktime_get_real_seconds();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct xfrm_mode xfrm6_ro_mode = {
|
||||
.output = xfrm6_ro_output,
|
||||
.owner = THIS_MODULE,
|
||||
.encap = XFRM_MODE_ROUTEOPTIMIZATION,
|
||||
.family = AF_INET6,
|
||||
|
@@ -15,31 +15,6 @@
|
||||
#include <net/xfrm.h>
|
||||
#include <net/protocol.h>
|
||||
|
||||
/* Add encapsulation header.
|
||||
*
|
||||
* The IP header and mutable extension headers will be moved forward to make
|
||||
* space for the encapsulation header.
|
||||
*/
|
||||
static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||
{
|
||||
struct ipv6hdr *iph;
|
||||
u8 *prevhdr;
|
||||
int hdr_len;
|
||||
|
||||
iph = ipv6_hdr(skb);
|
||||
skb_set_inner_transport_header(skb, skb_transport_offset(skb));
|
||||
|
||||
hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
|
||||
if (hdr_len < 0)
|
||||
return hdr_len;
|
||||
skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
|
||||
skb_set_network_header(skb, -x->props.header_len);
|
||||
skb->transport_header = skb->network_header + hdr_len;
|
||||
__skb_pull(skb, hdr_len);
|
||||
memmove(ipv6_hdr(skb), iph, hdr_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct sk_buff *xfrm4_transport_gso_segment(struct xfrm_state *x,
|
||||
struct sk_buff *skb,
|
||||
netdev_features_t features)
|
||||
@@ -70,7 +45,6 @@ static void xfrm6_transport_xmit(struct xfrm_state *x, struct sk_buff *skb)
|
||||
}
|
||||
|
||||
static struct xfrm_mode xfrm6_transport_mode = {
|
||||
.output = xfrm6_transport_output,
|
||||
.gso_segment = xfrm4_transport_gso_segment,
|
||||
.xmit = xfrm6_transport_xmit,
|
||||
.owner = THIS_MODULE,
|
||||
|
@@ -123,7 +123,6 @@ static void xfrm6_mode_tunnel_xmit(struct xfrm_state *x, struct sk_buff *skb)
|
||||
static struct xfrm_mode xfrm6_tunnel_mode = {
|
||||
.input2 = xfrm6_mode_tunnel_input,
|
||||
.output2 = xfrm6_mode_tunnel_output,
|
||||
.output = xfrm6_prepare_output,
|
||||
.gso_segment = xfrm6_mode_tunnel_gso_segment,
|
||||
.xmit = xfrm6_mode_tunnel_xmit,
|
||||
.owner = THIS_MODULE,
|
||||
|
@@ -111,21 +111,6 @@ int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||
return xfrm6_extract_header(skb);
|
||||
}
|
||||
|
||||
int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = xfrm_inner_extract_output(x, skb);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
skb->ignore_df = 1;
|
||||
skb->protocol = htons(ETH_P_IPV6);
|
||||
|
||||
return x->outer_mode->output2(x, skb);
|
||||
}
|
||||
EXPORT_SYMBOL(xfrm6_prepare_output);
|
||||
|
||||
int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
|
||||
|
Reference in New Issue
Block a user