ipsec offload: ipsec_accel_fill_xh() should indirect through fn pointer

The config with IPSEC_SUPPORT + IPSEC_OFFLOAD is the valid one.

Fixes:	5be5a0bde5
Sponsored by:	Nvidia networking
This commit is contained in:
Konstantin Belousov 2025-07-17 13:57:35 +03:00
parent 5be5a0bde5
commit 39598c2a9f
3 changed files with 21 additions and 5 deletions

View file

@ -160,6 +160,8 @@ static void ipsec_accel_drv_sa_lifetime_update_impl(struct secasvar *sav,
static int ipsec_accel_drv_sa_lifetime_fetch_impl(struct secasvar *sav,
if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs);
static void ipsec_accel_ifdetach_event(void *arg, struct ifnet *ifp);
static bool ipsec_accel_fill_xh_impl(if_t ifp, uint32_t drv_spi,
struct xform_history *xh);
static void
ipsec_accel_init(void *arg)
@ -186,6 +188,7 @@ ipsec_accel_init(void *arg)
ipsec_accel_drv_sa_lifetime_update_impl;
ipsec_accel_drv_sa_lifetime_fetch_p =
ipsec_accel_drv_sa_lifetime_fetch_impl;
ipsec_accel_fill_xh_p = ipsec_accel_fill_xh_impl;
pctrie_init(&drv_spi_pctrie);
ipsec_accel_ifdetach_event_tag = EVENTHANDLER_REGISTER(
ifnet_departure_event, ipsec_accel_ifdetach_event, NULL,
@ -210,6 +213,7 @@ ipsec_accel_fini(void *arg)
ipsec_accel_on_ifdown_p = NULL;
ipsec_accel_drv_sa_lifetime_update_p = NULL;
ipsec_accel_drv_sa_lifetime_fetch_p = NULL;
ipsec_accel_fill_xh_p = NULL;
ipsec_accel_sync_imp();
clean_unrhdr(drv_spi_unr); /* avoid panic, should go later */
clear_unrhdr(drv_spi_unr);
@ -1167,8 +1171,8 @@ ipsec_accel_key_setaccelif_impl(struct secasvar *sav)
return (m);
}
bool
ipsec_accel_fill_xh(if_t ifp, uint32_t drv_spi, struct xform_history *xh)
static bool
ipsec_accel_fill_xh_impl(if_t ifp, uint32_t drv_spi, struct xform_history *xh)
{
struct ifp_handle_sav *i;

View file

@ -68,6 +68,8 @@ extern void (*ipsec_accel_drv_sa_lifetime_update_p)(struct secasvar *sav,
if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs);
extern int (*ipsec_accel_drv_sa_lifetime_fetch_p)(struct secasvar *sav,
if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs);
extern bool (*ipsec_accel_fill_xh_p)(if_t ifp, uint32_t drv_spi,
struct xform_history *xh);
#ifdef IPSEC_OFFLOAD
/*
@ -160,6 +162,16 @@ ipsec_accel_key_setaccelif(struct secasvar *sav)
return (NULL);
}
static inline bool
ipsec_accel_fill_xh(if_t ifp, uint32_t drv_spi, struct xform_history *xh)
{
bool (*p)(if_t ifp, uint32_t drv_spi, struct xform_history *xh);
p = atomic_load_ptr(&ipsec_accel_fill_xh_p);
if (p != NULL)
return (p(ifp, drv_spi, xh));
return (false);
}
#else
#define ipsec_accel_sa_newkey(a)
@ -170,6 +182,7 @@ ipsec_accel_key_setaccelif(struct secasvar *sav)
#define ipsec_accel_sync()
#define ipsec_accel_is_accel_sav(a)
#define ipsec_accel_key_setaccelif(a)
#define ipsec_accel_fill_xh(a, b, c) (false)
#endif
void ipsec_accel_forget_sav_impl(struct secasvar *sav);
@ -183,8 +196,6 @@ bool ipsec_accel_output(struct ifnet *ifp, struct mbuf *m,
int mtu, int *hwassist);
void ipsec_accel_forget_sav(struct secasvar *sav);
struct xform_history;
bool ipsec_accel_fill_xh(if_t ifp, uint32_t drv_spi,
struct xform_history *xh);
#else
#define ipsec_accel_input(a, b, c) (ENXIO)
#define ipsec_accel_output(a, b, c, d, e, f, g, h) ({ \
@ -192,7 +203,6 @@ bool ipsec_accel_fill_xh(if_t ifp, uint32_t drv_spi,
false; \
})
#define ipsec_accel_forget_sav(a)
#define ipsec_accel_fill_xh(a, b, c) (false)
#endif
struct ipsec_accel_in_tag *ipsec_accel_input_tag_lookup(const struct mbuf *);

View file

@ -114,6 +114,8 @@ void (*ipsec_accel_drv_sa_lifetime_update_p)(struct secasvar *sav, if_t ifp,
u_int drv_spi, uint64_t octets, uint64_t allocs);
int (*ipsec_accel_drv_sa_lifetime_fetch_p)(struct secasvar *sav, if_t ifp,
u_int drv_spi, uint64_t *octets, uint64_t *allocs);
bool (*ipsec_accel_fill_xh_p)(if_t ifp, uint32_t drv_spi,
struct xform_history *xh);
#endif
#define FULLMASK 0xff