Commit 4f518e80 authored by Florian Westphal's avatar Florian Westphal Committed by Steffen Klassert
Browse files

xfrm: remove type and offload_type map from xfrm_state_afinfo



Only 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.

Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 4c203b04
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -348,8 +348,16 @@ int __xfrm_state_delete(struct xfrm_state *x);
struct xfrm_state_afinfo {
struct xfrm_state_afinfo {
	u8				family;
	u8				family;
	u8				proto;
	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)(struct net *net, struct sock *sk, struct sk_buff *skb);
	int			(*output_finish)(struct sock *sk, struct sk_buff *skb);
	int			(*output_finish)(struct sock *sk, struct sk_buff *skb);
@@ -401,7 +409,7 @@ struct xfrm_type {
};
};


int xfrm_register_type(const struct xfrm_type *type, unsigned short family);
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 {
struct xfrm_type_offload {
	char		*description;
	char		*description;
@@ -413,7 +421,7 @@ struct xfrm_type_offload {
};
};


int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family);
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)
static inline int xfrm_af2proto(unsigned int family)
{
{
+1 −2
Original line number Original line Diff line number Diff line
@@ -590,8 +590,7 @@ static void __exit ah4_fini(void)
{
{
	if (xfrm4_protocol_deregister(&ah4_protocol, IPPROTO_AH) < 0)
	if (xfrm4_protocol_deregister(&ah4_protocol, IPPROTO_AH) < 0)
		pr_info("%s: can't remove protocol\n", __func__);
		pr_info("%s: can't remove protocol\n", __func__);
	if (xfrm_unregister_type(&ah_type, AF_INET) < 0)
	xfrm_unregister_type(&ah_type, AF_INET);
		pr_info("%s: can't remove xfrm type\n", __func__);
}
}


module_init(ah4_init);
module_init(ah4_init);
+1 −2
Original line number Original line Diff line number Diff line
@@ -1066,8 +1066,7 @@ static void __exit esp4_fini(void)
{
{
	if (xfrm4_protocol_deregister(&esp4_protocol, IPPROTO_ESP) < 0)
	if (xfrm4_protocol_deregister(&esp4_protocol, IPPROTO_ESP) < 0)
		pr_info("%s: can't remove protocol\n", __func__);
		pr_info("%s: can't remove protocol\n", __func__);
	if (xfrm_unregister_type(&esp_type, AF_INET) < 0)
	xfrm_unregister_type(&esp_type, AF_INET);
		pr_info("%s: can't remove xfrm type\n", __func__);
}
}


module_init(esp4_init);
module_init(esp4_init);
+1 −3
Original line number Original line Diff line number Diff line
@@ -315,9 +315,7 @@ static int __init esp4_offload_init(void)


static void __exit esp4_offload_exit(void)
static void __exit esp4_offload_exit(void)
{
{
	if (xfrm_unregister_type_offload(&esp_type_offload, AF_INET) < 0)
	xfrm_unregister_type_offload(&esp_type_offload, AF_INET);
		pr_info("%s: can't remove xfrm type offload\n", __func__);

	inet_del_offload(&esp4_offload, IPPROTO_ESP);
	inet_del_offload(&esp4_offload, IPPROTO_ESP);
}
}


+1 −2
Original line number Original line Diff line number Diff line
@@ -190,8 +190,7 @@ static void __exit ipcomp4_fini(void)
{
{
	if (xfrm4_protocol_deregister(&ipcomp4_protocol, IPPROTO_COMP) < 0)
	if (xfrm4_protocol_deregister(&ipcomp4_protocol, IPPROTO_COMP) < 0)
		pr_info("%s: can't remove protocol\n", __func__);
		pr_info("%s: can't remove protocol\n", __func__);
	if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0)
	xfrm_unregister_type(&ipcomp_type, AF_INET);
		pr_info("%s: can't remove xfrm type\n", __func__);
}
}


module_init(ipcomp4_init);
module_init(ipcomp4_init);
Loading