xfrm: reduce xfrm_state_afinfo size
Subsystems (4)
cover xfrm: reduce xfrm_state_afinfo size
xfrm_state_afinfo is a very large struct; its over 4kbyte on 64bit systems.
The size comes from two arrays to store the l4 protocol type pointers (esp, ah, ipcomp and so on).
There are only a handful of those, so just use pointers for protocols that we implement instead of mostly-empty arrays.
This also removes the template init/sort related indirections. Structure size goes down to 120 bytes on x86_64.
include/net/xfrm.h | 49 ++--- net/ipv4/ah4.c | 3 net/ipv4/esp4.c | 3 net/ipv4/esp4_offload.c | 4 net/ipv4/ipcomp.c | 3 net/ipv4/xfrm4_state.c | 45 ----- net/ipv4/xfrm4_tunnel.c | 3 net/ipv6/ah6.c | 4 net/ipv6/esp6.c | 3 net/ipv6/esp6_offload.c | 4 net/ipv6/ipcomp6.c | 3 net/ipv6/mip6.c | 6 net/ipv6/xfrm6_state.c | 137 ---------------- net/xfrm/xfrm_input.c | 24 +- net/xfrm/xfrm_policy.c | 2 net/xfrm/xfrm_state.c | 400 +++++++++++++++++++++++++++++++++++------------- 16 files changed, 343 insertions(+), 350 deletions(-)
Florian Westphal (6):
xfrm: remove init_tempsel indirection from xfrm_state_afinfo
xfrm: remove init_temprop indirection from xfrm_state_afinfo
xfrm: remove init_flags indirection from xfrm_state_afinfo
xfrm: remove state and template sort indirections from xfrm_state_afinfo
xfrm: remove eth_proto value from xfrm_state_afinfo
xfrm: remove type and offload_type map from xfrm_state_afinfo
PATCH 1/6 xfrm: remove init_tempsel indirection from xfrm_state_afinfo
Simple initialization, handle it in the caller.
--- include/net/xfrm.h | 2 -- net/ipv4/xfrm4_state.c | 19 -------------- net/ipv6/xfrm6_state.c | 21 ---------------- net/xfrm/xfrm_state.c | 56 ++++++++++++++++++++++++++++++++++++------ 4 files changed, 49 insertions(+), 49 deletions(-)
include/net/xfrm.h +0 -2
@@ -353,8 +353,6 @@ struct xfrm_state_afinfo {const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX ];int (*init_flags)(struct xfrm_state *x); -void (*init_tempsel)(struct xfrm_selector *sel, -const struct flowi *fl); void (*init_temprop)(struct xfrm_state *x, const struct xfrm_tmpl *tmpl, const xfrm_address_t *daddr,
net/ipv4/xfrm4_state.c +0 -19
@@ -22,24 +22,6 @@ static int xfrm4_init_flags(struct xfrm_state *x)return 0 ; } -static void -__xfrm4_init_tempsel (struct xfrm_selector *sel,const struct flowi *fl) -{ -const struct flowi4 *fl4 = &fl->u.ip4; - - sel->daddr.a4 = fl4->daddr; - sel->saddr.a4 = fl4->saddr; - sel->dport =xfrm_flowi_dport (fl, &fl4->uli); - sel->dport_mask =htons (0xffff ); - sel->sport =xfrm_flowi_sport (fl, &fl4->uli); - sel->sport_mask =htons (0xffff ); - sel->family =AF_INET ; - sel->prefixlen_d =32 ; - sel->prefixlen_s =32 ; - sel->proto = fl4->flowi4_proto; - sel->ifindex = fl4->flowi4_oif; -} -static void xfrm4_init_temprop (struct xfrm_state *x,const struct xfrm_tmpl *tmpl,const xfrm_address_t *daddr,const xfrm_address_t *saddr)
@@ -77,7 +59,6 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = { .eth_proto = htons(ETH_P_IP), .owner = THIS_MODULE, .init_flags = xfrm4_init_flags, - .init_tempsel = __xfrm4_init_tempsel, .init_temprop = xfrm4_init_temprop, .output = xfrm4_output, .output_finish = xfrm4_output_finish,
net/ipv6/xfrm6_state.c +0 -21
@@ -21,26 +21,6 @@#include <net/ipv6.h> #include <net/addrconf.h> -static void -__xfrm6_init_tempsel (struct xfrm_selector *sel,const struct flowi *fl) -{ -const struct flowi6 *fl6 = &fl->u.ip6; - -/* Initialize temporary selector matching only -* to current session. */ - *(struct in6_addr *)&sel->daddr = fl6->daddr; - *(struct in6_addr *)&sel->saddr = fl6->saddr; - sel->dport =xfrm_flowi_dport (fl, &fl6->uli); - sel->dport_mask =htons (0xffff ); - sel->sport =xfrm_flowi_sport (fl, &fl6->uli); - sel->sport_mask =htons (0xffff ); - sel->family =AF_INET6 ; - sel->prefixlen_d =128 ; - sel->prefixlen_s =128 ; - sel->proto = fl6->flowi6_proto; - sel->ifindex = fl6->flowi6_oif; -} -static void xfrm6_init_temprop (struct xfrm_state *x,const struct xfrm_tmpl *tmpl,const xfrm_address_t *daddr,const xfrm_address_t *saddr)
@@ -173,7 +153,6 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = { .proto = IPPROTO_IPV6, .eth_proto = htons(ETH_P_IPV6), .owner = THIS_MODULE, - .init_tempsel = __xfrm6_init_tempsel, .init_temprop = xfrm6_init_temprop, .tmpl_sort = __xfrm6_tmpl_sort, .state_sort = __xfrm6_state_sort,
net/xfrm/xfrm_state.c +49 -7
71 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 2/6 xfrm: remove init_temprop indirection from xfrm_state_afinfo
In reply to Florian Westphalsame as previous patch: just place this in the caller, no need to have an indirection for a structure initialization.
--- include/net/xfrm.h | 4 ---- net/ipv4/xfrm4_state.c | 16 ---------------- net/ipv6/xfrm6_state.c | 16 ---------------- net/xfrm/xfrm_state.c | 27 ++++++++++++++++++++------- 4 files changed, 20 insertions(+), 43 deletions(-)
include/net/xfrm.h +0 -4
@@ -353,10 +353,6 @@ struct xfrm_state_afinfo {const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX ];int (*init_flags)(struct xfrm_state *x); -void (*init_temprop)(struct xfrm_state *x, -const struct xfrm_tmpl *tmpl, -const xfrm_address_t *daddr, -const xfrm_address_t *saddr);int (*tmpl_sort)(struct xfrm_tmpl **dst,struct xfrm_tmpl **src,int n);int (*state_sort)(struct xfrm_state **dst,struct xfrm_state **src,int n);int (*output)(struct net *net,struct sock *sk,struct sk_buff *skb);
net/ipv4/xfrm4_state.c +0 -16
@@ -22,21 +22,6 @@ static int xfrm4_init_flags(struct xfrm_state *x)return 0 ; } -static void -xfrm4_init_temprop (struct xfrm_state *x,const struct xfrm_tmpl *tmpl, -const xfrm_address_t *daddr,const xfrm_address_t *saddr) -{ - x->id = tmpl->id; -if (x->id.daddr.a4 ==0 ) - x->id.daddr.a4 = daddr->a4; - x->props.saddr = tmpl->saddr; -if (x->props.saddr.a4 ==0 ) - x->props.saddr.a4 = saddr->a4; - x->props.mode = tmpl->mode; - x->props.reqid = tmpl->reqid; - x->props.family =AF_INET ; -} -int xfrm4_extract_header (struct sk_buff *skb) {const struct iphdr *iph =ip_hdr (skb);
@@ -59,7 +44,6 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = { .eth_proto = htons(ETH_P_IP), .owner = THIS_MODULE, .init_flags = xfrm4_init_flags, - .init_temprop = xfrm4_init_temprop, .output = xfrm4_output, .output_finish = xfrm4_output_finish, .extract_input = xfrm4_extract_input,
net/ipv6/xfrm6_state.c +0 -16
@@ -21,21 +21,6 @@#include <net/ipv6.h> #include <net/addrconf.h> -static void -xfrm6_init_temprop (struct xfrm_state *x,const struct xfrm_tmpl *tmpl, -const xfrm_address_t *daddr,const xfrm_address_t *saddr) -{ - x->id = tmpl->id; -if (ipv6_addr_any ((struct in6_addr *)&x->id.daddr)) -memcpy (&x->id.daddr, daddr,sizeof (x->sel.daddr)); -memcpy (&x->props.saddr, &tmpl->saddr,sizeof (x->props.saddr)); -if (ipv6_addr_any ((struct in6_addr *)&x->props.saddr)) -memcpy (&x->props.saddr, saddr,sizeof (x->props.saddr)); - x->props.mode = tmpl->mode; - x->props.reqid = tmpl->reqid; - x->props.family =AF_INET6 ; -} -/* distribution counting sort function for xfrm_state and xfrm_tmpl */ static int __xfrm6_sort (void **dst,void **src,int n,int (*cmp)(void *p),int maxclass)
@@ -153,7 +138,6 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = { .proto = IPPROTO_IPV6, .eth_proto = htons(ETH_P_IPV6), .owner = THIS_MODULE, - .init_temprop = xfrm6_init_temprop, .tmpl_sort = __xfrm6_tmpl_sort, .state_sort = __xfrm6_state_sort, .output = xfrm6_output,
net/xfrm/xfrm_state.c +20 -7
@@ -810,8 +810,6 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl, const xfrm_address_t *daddr, const xfrm_address_t *saddr, unsigned short family) { - struct xfrm_state_afinfo *afinfo = xfrm_state_afinfo_get_rcu(family); - switch (family) { case AF_INET: __xfrm4_init_tempsel(&x->sel, fl);
@@ -821,13 +819,28 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl,break ; } -if (family != tmpl->encap_family) - afinfo =xfrm_state_afinfo_get_rcu (tmpl->encap_family); + x->id = tmpl->id; -if (!afinfo) -return ; +switch (tmpl->encap_family) { +case AF_INET : +if (x->id.daddr.a4 ==0 ) + x->id.daddr.a4 = daddr->a4; + x->props.saddr = tmpl->saddr; +if (x->props.saddr.a4 ==0 ) + x->props.saddr.a4 = saddr->a4; +break ; +case AF_INET6 : +if (ipv6_addr_any ((struct in6_addr *)&x->id.daddr)) +memcpy (&x->id.daddr, daddr,sizeof (x->sel.daddr)); +memcpy (&x->props.saddr, &tmpl->saddr,sizeof (x->props.saddr)); +if (ipv6_addr_any ((struct in6_addr *)&x->props.saddr)) +memcpy (&x->props.saddr, saddr,sizeof (x->props.saddr)); +break ; + } - afinfo->init_temprop (x, tmpl, daddr, saddr); + x->props.mode = tmpl->mode; + x->props.reqid = tmpl->reqid; + x->props.family = tmpl->encap_family; } static struct xfrm_state *__xfrm_state_lookup(struct net *net, u32 mark,
Signature · 1 line
2.21.0
PATCH 3/6 xfrm: remove init_flags indirection from xfrm_state_afinfo
In reply to Florian WestphalThere is only one implementation of this function; just call it directly.
--- include/net/xfrm.h | 1 - net/ipv4/xfrm4_state.c | 8 -------- net/xfrm/xfrm_state.c | 17 +++-------------- 3 files changed, 3 insertions(+), 23 deletions(-)
include/net/xfrm.h +0 -1
@@ -352,7 +352,6 @@ struct xfrm_state_afinfo {const struct xfrm_type *type_map[IPPROTO_MAX ];const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX ]; -int (*init_flags)(struct xfrm_state *x);int (*tmpl_sort)(struct xfrm_tmpl **dst,struct xfrm_tmpl **src,int n);int (*state_sort)(struct xfrm_state **dst,struct xfrm_state **src,int n);int (*output)(struct net *net,struct sock *sk,struct sk_buff *skb);
net/ipv4/xfrm4_state.c +0 -8
@@ -15,13 +15,6 @@#include <linux/netfilter_ipv4.h> #include <linux/export.h> -static int xfrm4_init_flags (struct xfrm_state *x) -{ -if (xs_net (x)->ipv4.sysctl_ip_no_pmtu_disc) - x->props.flags |=XFRM_STATE_NOPMTUDISC ; -return 0 ; -} -int xfrm4_extract_header (struct sk_buff *skb) {const struct iphdr *iph =ip_hdr (skb);
@@ -43,7 +36,6 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = { .proto = IPPROTO_IPIP, .eth_proto = htons(ETH_P_IP), .owner = THIS_MODULE, - .init_flags = xfrm4_init_flags, .output = xfrm4_output, .output_finish = xfrm4_output_finish, .extract_input = xfrm4_extract_input,
net/xfrm/xfrm_state.c +3 -14
@@ -2256,25 +2256,14 @@ int xfrm_state_mtu(struct xfrm_state *x, int mtu)int __xfrm_init_state (struct xfrm_state *x,bool init_replay,bool offload) { -const struct xfrm_state_afinfo *afinfo;const struct xfrm_mode *inner_mode;const struct xfrm_mode *outer_mode;int family = x->props.family;int err; - err = -EAFNOSUPPORT ; - afinfo =xfrm_state_get_afinfo (family); -if (!afinfo) - goto error; - - err =0 ; -if (afinfo->init_flags) - err = afinfo->init_flags (x); - -rcu_read_unlock (); - -if (err) - goto error; +if (family ==AF_INET && +xs_net (x)->ipv4.sysctl_ip_no_pmtu_disc) + x->props.flags |=XFRM_STATE_NOPMTUDISC ; err = -EPROTONOSUPPORT ;
Signature · 1 line
2.21.0
PATCH 4/6 xfrm: remove state and template sort indirections from xfrm_state_afinfo
In reply to Florian WestphalNo module dependency, placing this in xfrm_state.c avoids need for an indirection.
This also removes the state spinlock -- I don't see why we would need to hold it during sorting.
This in turn allows to remove the 'net' argument passed to xfrm_tmpl_sort. Last, remove the EXPORT_SYMBOL, there are no modular callers.
For the CONFIG_IPV6=m case, vmlinux size increase is about 300 byte.
--- include/net/xfrm.h | 18 +++--- net/ipv6/xfrm6_state.c | 98 ------------------------------- net/xfrm/xfrm_policy.c | 2 +- net/xfrm/xfrm_state.c | 129 ++++++++++++++++++++++++++++++++--------- 4 files changed, 110 insertions(+), 137 deletions(-)
include/net/xfrm.h +7 -11
@@ -352,8 +352,6 @@ struct xfrm_state_afinfo {const struct xfrm_type *type_map[IPPROTO_MAX ];const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX ]; -int (*tmpl_sort)(struct xfrm_tmpl **dst,struct xfrm_tmpl **src,int n); -int (*state_sort)(struct xfrm_state **dst,struct xfrm_state **src,int n);int (*output)(struct net *net,struct sock *sk,struct sk_buff *skb);int (*output_finish)(struct sock *sk,struct sk_buff *skb); int (*extract_input)(struct xfrm_state *x,
@@ -1483,21 +1481,19 @@ struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark,u8 proto, unsigned short family);#ifdef CONFIG_XFRM_SUB_POLICY -int xfrm_tmpl_sort (struct xfrm_tmpl **dst,struct xfrm_tmpl **src,int n, -unsigned short family,struct net *net); -int xfrm_state_sort (struct xfrm_state **dst,struct xfrm_state **src,int n, +void xfrm_tmpl_sort (struct xfrm_tmpl **dst,struct xfrm_tmpl **src,int n,unsigned short family); +void xfrm_state_sort (struct xfrm_state **dst,struct xfrm_state **src,int n, +unsigned short family);#else -static inline int xfrm_tmpl_sort (struct xfrm_tmpl **dst,struct xfrm_tmpl **src, -int n,unsigned short family,struct net *net) +static inline void xfrm_tmpl_sort (struct xfrm_tmpl **d,struct xfrm_tmpl **s, +int n,unsigned short family) { -return -ENOSYS ; } -static inline int xfrm_state_sort (struct xfrm_state **dst,struct xfrm_state **src, -int n,unsigned short family) +static inline void xfrm_state_sort (struct xfrm_state **d,struct xfrm_state **s, +int n,unsigned short family) { -return -ENOSYS ; }#endif
net/ipv6/xfrm6_state.c +0 -98
110 lines not on this page · raw message
net/xfrm/xfrm_policy.c +1 -1
@@ -3625,7 +3625,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, } xfrm_nr = ti;if (npols >1 ) { -xfrm_tmpl_sort (stp, tpp, xfrm_nr, family, net); +xfrm_tmpl_sort (stp, tpp, xfrm_nr, family); tpp = stp; }
net/xfrm/xfrm_state.c +102 -27
153 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 5/6 xfrm: remove eth_proto value from xfrm_state_afinfo
In reply to Florian Westphalxfrm_prepare_input needs to lookup the state afinfo backend again to fetch the address family ethernet protocol value.
There are only two address families, so a switch statement is simpler. While at it, use u8 for family and proto and remove the owner member -- its not used anywhere.
--- include/net/xfrm.h | 6 ++---- net/ipv4/xfrm4_state.c | 2 -- net/ipv6/xfrm6_state.c | 2 -- net/xfrm/xfrm_input.c | 24 ++++++++++++------------ 4 files changed, 14 insertions(+), 20 deletions(-)
include/net/xfrm.h +2 -4
@@ -345,10 +345,8 @@ void km_state_expired(struct xfrm_state *x, int hard, u32 portid);int __xfrm_state_delete (struct xfrm_state *x);struct xfrm_state_afinfo { -unsigned int family; -unsigned int proto; -__be16 eth_proto; -struct module *owner; +u8 family; +u8 proto;const struct xfrm_type *type_map[IPPROTO_MAX ];const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX ];
net/ipv4/xfrm4_state.c +0 -2
@@ -34,8 +34,6 @@ int xfrm4_extract_header(struct sk_buff *skb)static struct xfrm_state_afinfo xfrm4_state_afinfo = { .family =AF_INET , .proto =IPPROTO_IPIP , - .eth_proto =htons (ETH_P_IP ), - .owner =THIS_MODULE , .output = xfrm4_output, .output_finish = xfrm4_output_finish, .extract_input = xfrm4_extract_input,
net/ipv6/xfrm6_state.c +0 -2
@@ -40,8 +40,6 @@ int xfrm6_extract_header(struct sk_buff *skb)static struct xfrm_state_afinfo xfrm6_state_afinfo = { .family =AF_INET6 , .proto =IPPROTO_IPV6 , - .eth_proto =htons (ETH_P_IPV6 ), - .owner =THIS_MODULE , .output = xfrm6_output, .output_finish = xfrm6_output_finish, .extract_input = xfrm6_extract_input,
net/xfrm/xfrm_input.c +12 -12
@@ -359,28 +359,28 @@ static int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb) afinfo =xfrm_state_afinfo_get_rcu (x->outer_mode.family);if (likely (afinfo)) err = afinfo->extract_input (x, skb); +rcu_read_unlock (); -if (err) { -rcu_read_unlock (); +if (err)return err; - }if (x->sel.family ==AF_UNSPEC ) { inner_mode =xfrm_ip2inner_mode (x,XFRM_MODE_SKB_CB (skb)->protocol); -if (!inner_mode) { -rcu_read_unlock (); +if (!inner_mode)return -EAFNOSUPPORT ; - } } - afinfo =xfrm_state_afinfo_get_rcu (inner_mode->family); -if (unlikely (!afinfo)) { -rcu_read_unlock (); -return -EAFNOSUPPORT ; +switch (inner_mode->family) { +case AF_INET : + skb->protocol =htons (ETH_P_IP ); +break ; +case AF_INET6 : + skb->protocol =htons (ETH_P_IPV6 ); +default : +WARN_ON_ONCE (1 ); +break ; } - skb->protocol = afinfo->eth_proto; -rcu_read_unlock ();return xfrm_inner_mode_encap_remove (x, inner_mode, skb); }
Signature · 1 line
2.21.0
PATCH 6/6 xfrm: remove type and offload_type map from xfrm_state_afinfo
In reply to Florian WestphalOnly a handful of xfrm_types exist, no need to have 512 pointers for them.
Reduces size of afinfo struct from 4k to 120 bytes on 64bit platforms.
Also, the unregister function doesn't need to return an error, no single caller does anything useful with it.
Just place a WARN_ON() where needed instead.
--- include/net/xfrm.h | 16 +++- net/ipv4/ah4.c | 3 +- net/ipv4/esp4.c | 3 +- net/ipv4/esp4_offload.c | 4 +- net/ipv4/ipcomp.c | 3 +- net/ipv4/xfrm4_tunnel.c | 3 +- net/ipv6/ah6.c | 4 +- net/ipv6/esp6.c | 3 +- net/ipv6/esp6_offload.c | 4 +- net/ipv6/ipcomp6.c | 3 +- net/ipv6/mip6.c | 6 +- net/xfrm/xfrm_state.c | 179 ++++++++++++++++++++++++++++------------ 12 files changed, 150 insertions(+), 81 deletions(-)
include/net/xfrm.h +12 -4
@@ -347,8 +347,16 @@ int __xfrm_state_delete(struct xfrm_state *x);struct xfrm_state_afinfo {u8 family;u8 proto; -const struct xfrm_type *type_map[IPPROTO_MAX ]; -const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX ]; + +const struct xfrm_type_offload *type_offload_esp; + +const struct xfrm_type *type_esp; +const struct xfrm_type *type_ipip; +const struct xfrm_type *type_ipip6; +const struct xfrm_type *type_comp; +const struct xfrm_type *type_ah; +const struct xfrm_type *type_routing; +const struct xfrm_type *type_dstopts;int (*output)(struct net *net,struct sock *sk,struct sk_buff *skb);int (*output_finish)(struct sock *sk,struct sk_buff *skb);
@@ -400,7 +408,7 @@ struct xfrm_type { };int xfrm_register_type (const struct xfrm_type *type,unsigned short family); -int xfrm_unregister_type (const struct xfrm_type *type,unsigned short family); +void xfrm_unregister_type (const struct xfrm_type *type,unsigned short family);struct xfrm_type_offload {char *description;
@@ -412,7 +420,7 @@ struct xfrm_type_offload { };int xfrm_register_type_offload (const struct xfrm_type_offload *type,unsigned short family); -int xfrm_unregister_type_offload (const struct xfrm_type_offload *type,unsigned short family); +void xfrm_unregister_type_offload (const struct xfrm_type_offload *type,unsigned short family);static inline int xfrm_af2proto (unsigned int family) {
net/ipv4/ah4.c +1 -2
@@ -589,8 +589,7 @@ static void __exit ah4_fini(void) {if (xfrm4_protocol_deregister (&ah4_protocol,IPPROTO_AH ) <0 )pr_info ("%s: can't remove protocol\n" , __func__); -if (xfrm_unregister_type (&ah_type,AF_INET ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); +xfrm_unregister_type (&ah_type,AF_INET ); }module_init (ah4_init);
net/ipv4/esp4.c +1 -2
@@ -1055,8 +1055,7 @@ static void __exit esp4_fini(void) {if (xfrm4_protocol_deregister (&esp4_protocol,IPPROTO_ESP ) <0 )pr_info ("%s: can't remove protocol\n" , __func__); -if (xfrm_unregister_type (&esp_type,AF_INET ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); +xfrm_unregister_type (&esp_type,AF_INET ); }module_init (esp4_init);
net/ipv4/esp4_offload.c +1 -3
@@ -313,9 +313,7 @@ static int __init esp4_offload_init(void) static void __exit esp4_offload_exit(void) { -if (xfrm_unregister_type_offload (&esp_type_offload,AF_INET ) <0 ) -pr_info ("%s: can't remove xfrm type offload\n" , __func__); - +xfrm_unregister_type_offload (&esp_type_offload,AF_INET );inet_del_offload (&esp4_offload,IPPROTO_ESP ); }
net/ipv4/ipcomp.c +1 -2
@@ -190,8 +190,7 @@ static void __exit ipcomp4_fini(void) {if (xfrm4_protocol_deregister (&ipcomp4_protocol,IPPROTO_COMP ) <0 )pr_info ("%s: can't remove protocol\n" , __func__); -if (xfrm_unregister_type (&ipcomp_type,AF_INET ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); +xfrm_unregister_type (&ipcomp_type,AF_INET ); }module_init (ipcomp4_init);
net/ipv4/xfrm4_tunnel.c +1 -2
@@ -107,8 +107,7 @@ static void __exit ipip_fini(void)if (xfrm4_tunnel_deregister (&xfrm_tunnel_handler,AF_INET ))pr_info ("%s: can't remove xfrm handler for AF_INET\n" , __func__); -if (xfrm_unregister_type (&ipip_type,AF_INET ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); +xfrm_unregister_type (&ipip_type,AF_INET ); }module_init (ipip_init);
net/ipv6/ah6.c +1 -3
@@ -805,9 +805,7 @@ static void __exit ah6_fini(void)if (xfrm6_protocol_deregister (&ah6_protocol,IPPROTO_AH ) <0 )pr_info ("%s: can't remove protocol\n" , __func__); -if (xfrm_unregister_type (&ah6_type,AF_INET6 ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); - +xfrm_unregister_type (&ah6_type,AF_INET6 ); }module_init (ah6_init);
net/ipv6/esp6.c +1 -2
@@ -963,8 +963,7 @@ static void __exit esp6_fini(void) {if (xfrm6_protocol_deregister (&esp6_protocol,IPPROTO_ESP ) <0 )pr_info ("%s: can't remove protocol\n" , __func__); -if (xfrm_unregister_type (&esp6_type,AF_INET6 ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); +xfrm_unregister_type (&esp6_type,AF_INET6 ); }module_init (esp6_init);
net/ipv6/esp6_offload.c +1 -3
@@ -337,9 +337,7 @@ static int __init esp6_offload_init(void) static void __exit esp6_offload_exit(void) { -if (xfrm_unregister_type_offload (&esp6_type_offload,AF_INET6 ) <0 ) -pr_info ("%s: can't remove xfrm type offload\n" , __func__); - +xfrm_unregister_type_offload (&esp6_type_offload,AF_INET6 );inet6_del_offload (&esp6_offload,IPPROTO_ESP ); }
net/ipv6/ipcomp6.c +1 -2
@@ -218,8 +218,7 @@ static void __exit ipcomp6_fini(void) {if (xfrm6_protocol_deregister (&ipcomp6_protocol,IPPROTO_COMP ) <0 )pr_info ("%s: can't remove protocol\n" , __func__); -if (xfrm_unregister_type (&ipcomp6_type,AF_INET6 ) <0 ) -pr_info ("%s: can't remove xfrm type\n" , __func__); +xfrm_unregister_type (&ipcomp6_type,AF_INET6 ); }module_init (ipcomp6_init);
net/ipv6/mip6.c +2 -4
@@ -511,10 +511,8 @@ static void __exit mip6_fini(void) {if (rawv6_mh_filter_unregister (mip6_mh_filter) <0 )pr_info ("%s: can't remove rawv6 mh filter\n" , __func__); -if (xfrm_unregister_type (&mip6_rthdr_type,AF_INET6 ) <0 ) -pr_info ("%s: can't remove xfrm type(rthdr)\n" , __func__); -if (xfrm_unregister_type (&mip6_destopt_type,AF_INET6 ) <0 ) -pr_info ("%s: can't remove xfrm type(destopt)\n" , __func__); +xfrm_unregister_type (&mip6_rthdr_type,AF_INET6 ); +xfrm_unregister_type (&mip6_destopt_type,AF_INET6 ); }module_init (mip6_init);
net/xfrm/xfrm_state.c +127 -52
255 lines not on this page · raw message
Signature · 1 line
2.21.0
Steffen Klassert
maintainerQuoted 29 lines · Florian Westphal
xfrm_state_afinfois a very large struct; its over 4kbyte on 64bit systems.The size comes from two arrays to store the l4 protocol type pointers (esp, ah, ipcomp and so on).
There are only a handful of those, so just use pointers for protocols that we implement instead of mostly-empty arrays.
This also removes the template init/sort related indirections. Structure size goes down to 120 bytes on
x86_64.include/net/xfrm.h | 49 ++--- net/ipv4/ah4.c | 3 net/ipv4/esp4.c | 3 net/ipv4/esp4_offload.c | 4 net/ipv4/ipcomp.c | 3 net/ipv4/xfrm4_state.c | 45 ----- net/ipv4/xfrm4_tunnel.c | 3 net/ipv6/ah6.c | 4 net/ipv6/esp6.c | 3 net/ipv6/esp6_offload.c | 4 net/ipv6/ipcomp6.c | 3 net/ipv6/mip6.c | 6 net/ipv6/xfrm6_state.c | 137 ---------------- net/xfrm/xfrm_input.c | 24 +- net/xfrm/xfrm_policy.c | 2 net/xfrm/xfrm_state.c | 400 +++++++++++++++++++++++++++++++++++------------- 16 files changed, 343 insertions(+), 350 deletions(-)
Quoted 7 lines
Florian Westphal (6):
xfrm: removeinit_tempselindirection fromxfrm_state_afinfo
xfrm: removeinit_tempropindirection fromxfrm_state_afinfo
xfrm: removeinit_flagsindirection fromxfrm_state_afinfo
xfrm: remove state and template sort indirections fromxfrm_state_afinfo
xfrm: removeeth_protovalue fromxfrm_state_afinfo
xfrm: remove type andoffload_typemap fromxfrm_state_afinfo
I have deferred this until after the merge window. I'll consider applying them then.
Thanks!
Steffen Klassert
maintainerQuoted 38 lines · Steffen Klassert
Quoted 29 lines · Florian Westphal
xfrm_state_afinfois a very large struct; its over 4kbyte on 64bit systems.The size comes from two arrays to store the l4 protocol type pointers (esp, ah, ipcomp and so on).
There are only a handful of those, so just use pointers for protocols that we implement instead of mostly-empty arrays.
This also removes the template init/sort related indirections. Structure size goes down to 120 bytes on
x86_64.include/net/xfrm.h | 49 ++--- net/ipv4/ah4.c | 3 net/ipv4/esp4.c | 3 net/ipv4/esp4_offload.c | 4 net/ipv4/ipcomp.c | 3 net/ipv4/xfrm4_state.c | 45 ----- net/ipv4/xfrm4_tunnel.c | 3 net/ipv6/ah6.c | 4 net/ipv6/esp6.c | 3 net/ipv6/esp6_offload.c | 4 net/ipv6/ipcomp6.c | 3 net/ipv6/mip6.c | 6 net/ipv6/xfrm6_state.c | 137 ---------------- net/xfrm/xfrm_input.c | 24 +- net/xfrm/xfrm_policy.c | 2 net/xfrm/xfrm_state.c | 400 +++++++++++++++++++++++++++++++++++------------- 16 files changed, 343 insertions(+), 350 deletions(-)Quoted 7 lines
Florian Westphal (6):
xfrm: removeinit_tempselindirection fromxfrm_state_afinfo
xfrm: removeinit_tempropindirection fromxfrm_state_afinfo
xfrm: removeinit_flagsindirection fromxfrm_state_afinfo
xfrm: remove state and template sort indirections fromxfrm_state_afinfo
xfrm: removeeth_protovalue fromxfrm_state_afinfo
xfrm: remove type andoffload_typemap fromxfrm_state_afinfo
Quoted 2 lines
I have deferred this until after the merge window. I'll consider applying them then.
This is now applied to ipsec-next, thanks Florian!