mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-03 01:36:52 +09:00
xfrm: Remove xfrmi interface ID from flowi
In order to remove performance impact of having the extra u32 in every single flowi, this change removes the flowi_xfrm struct, prefering to take the if_id as a method parameter where needed. In the inbound direction, if_id is only needed during the __xfrm_check_policy() function, and the if_id can be determined at that point based on the skb. As such, xfrmi_decode_session() is only called with the skb in __xfrm_check_policy(). In the outbound direction, the only place where if_id is needed is the xfrm_lookup() call in xfrmi_xmit2(). With this change, the if_id is directly passed into the xfrm_lookup_with_ifid() call. All existing callers can still call xfrm_lookup(), which uses a default if_id of 0. This change does not change any behavior of XFRMIs except for improving overall system performance via flowi size reduction. This change has been tested against the Android Kernel Networking Tests: https://android.googlesource.com/kernel/tests/+/master/net/test Signed-off-by: Benedict Wong <benedictwong@google.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
committed by
Steffen Klassert
parent
fcb662deeb
commit
bc56b33404
@@ -475,6 +475,14 @@ static inline struct dst_entry *xfrm_lookup(struct net *net,
|
||||
return dst_orig;
|
||||
}
|
||||
|
||||
static inline struct dst_entry *
|
||||
xfrm_lookup_with_ifid(struct net *net, struct dst_entry *dst_orig,
|
||||
const struct flowi *fl, const struct sock *sk,
|
||||
int flags, u32 if_id)
|
||||
{
|
||||
return dst_orig;
|
||||
}
|
||||
|
||||
static inline struct dst_entry *xfrm_lookup_route(struct net *net,
|
||||
struct dst_entry *dst_orig,
|
||||
const struct flowi *fl,
|
||||
@@ -494,6 +502,12 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
|
||||
const struct flowi *fl, const struct sock *sk,
|
||||
int flags);
|
||||
|
||||
struct dst_entry *xfrm_lookup_with_ifid(struct net *net,
|
||||
struct dst_entry *dst_orig,
|
||||
const struct flowi *fl,
|
||||
const struct sock *sk, int flags,
|
||||
u32 if_id);
|
||||
|
||||
struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
|
||||
const struct flowi *fl, const struct sock *sk,
|
||||
int flags);
|
||||
|
||||
@@ -26,10 +26,6 @@ struct flowi_tunnel {
|
||||
__be64 tun_id;
|
||||
};
|
||||
|
||||
struct flowi_xfrm {
|
||||
__u32 if_id;
|
||||
};
|
||||
|
||||
struct flowi_common {
|
||||
int flowic_oif;
|
||||
int flowic_iif;
|
||||
@@ -43,7 +39,6 @@ struct flowi_common {
|
||||
#define FLOWI_FLAG_SKIP_NH_OIF 0x04
|
||||
__u32 flowic_secid;
|
||||
struct flowi_tunnel flowic_tun_key;
|
||||
struct flowi_xfrm xfrm;
|
||||
kuid_t flowic_uid;
|
||||
};
|
||||
|
||||
@@ -83,7 +78,6 @@ struct flowi4 {
|
||||
#define flowi4_secid __fl_common.flowic_secid
|
||||
#define flowi4_tun_key __fl_common.flowic_tun_key
|
||||
#define flowi4_uid __fl_common.flowic_uid
|
||||
#define flowi4_xfrm __fl_common.xfrm
|
||||
|
||||
/* (saddr,daddr) must be grouped, same order as in IP header */
|
||||
__be32 saddr;
|
||||
@@ -115,7 +109,6 @@ static inline void flowi4_init_output(struct flowi4 *fl4, int oif,
|
||||
fl4->flowi4_flags = flags;
|
||||
fl4->flowi4_secid = 0;
|
||||
fl4->flowi4_tun_key.tun_id = 0;
|
||||
fl4->flowi4_xfrm.if_id = 0;
|
||||
fl4->flowi4_uid = uid;
|
||||
fl4->daddr = daddr;
|
||||
fl4->saddr = saddr;
|
||||
@@ -145,7 +138,6 @@ struct flowi6 {
|
||||
#define flowi6_secid __fl_common.flowic_secid
|
||||
#define flowi6_tun_key __fl_common.flowic_tun_key
|
||||
#define flowi6_uid __fl_common.flowic_uid
|
||||
#define flowi6_xfrm __fl_common.xfrm
|
||||
struct in6_addr daddr;
|
||||
struct in6_addr saddr;
|
||||
/* Note: flowi6_tos is encoded in flowlabel, too. */
|
||||
@@ -193,7 +185,6 @@ struct flowi {
|
||||
#define flowi_secid u.__fl_common.flowic_secid
|
||||
#define flowi_tun_key u.__fl_common.flowic_tun_key
|
||||
#define flowi_uid u.__fl_common.flowic_uid
|
||||
#define flowi_xfrm u.__fl_common.xfrm
|
||||
} __attribute__((__aligned__(BITS_PER_LONG/8)));
|
||||
|
||||
static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4)
|
||||
|
||||
@@ -1557,7 +1557,7 @@ struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr,
|
||||
const struct flowi *fl,
|
||||
struct xfrm_tmpl *tmpl,
|
||||
struct xfrm_policy *pol, int *err,
|
||||
unsigned short family);
|
||||
unsigned short family, u32 if_id);
|
||||
struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark, u32 if_id,
|
||||
xfrm_address_t *daddr,
|
||||
xfrm_address_t *saddr,
|
||||
|
||||
Reference in New Issue
Block a user