From e9124f79c2a6cccc49f2579e48b18136f3737722 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Sun, 6 Aug 2023 15:47:51 +0000 Subject: [PATCH] temp: get compiling --- include/net/xfrm.h | 6 +++--- net/xfrm/xfrm_iptfs.c | 25 +++++++++++-------------- net/xfrm/xfrm_policy.c | 2 +- net/xfrm/xfrm_state.c | 21 ++++++++++----------- net/xfrm/xfrm_user.c | 12 +++++++++--- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 0f1066d1deec20..e03aa4181bdd37 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -452,14 +452,14 @@ struct xfrm_mode_cbs { int (*user_init)(struct net *net, struct xfrm_state *x, struct nlattr **attrs); int (*copy_to_user)(struct xfrm_state *x, struct sk_buff *skb); - void (*input)(struct xfrm_state *x, struct sk_buff *skb); + int (*input)(struct xfrm_state *x, struct sk_buff *skb); void (*xmit_prep)(struct xfrm_state *x, struct sk_buff *skb); int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb); }; -int xfrm_register_mode_cbs(const struct xfrm_mode_cbs *mode_cbs); -void xfrm_unregister_mode_cbs(const struct xfrm_mode_cbs *mode_cbs); +int xfrm_register_mode_cbs(u8, const struct xfrm_mode_cbs *mode_cbs); +void xfrm_unregister_mode_cbs(u8); const struct xfrm_mode_cbs *xfrm_get_mode_cbs(u8 mode, bool try_load); static inline int xfrm_af2proto(unsigned int family) diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c index f1948c6686b6e4..712ccbd3b82765 100644 --- a/net/xfrm/xfrm_iptfs.c +++ b/net/xfrm/xfrm_iptfs.c @@ -330,8 +330,7 @@ static uint __iptfs_iplen(u8 *data) */ static void iptfs_complete_inner_skb(struct xfrm_state *x, struct sk_buff *skb) { - struct sec_path *sp; - int err, family; + int family; skb_reset_network_header(skb); @@ -586,8 +585,7 @@ static uint iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq, /* * We have an IPTFS payload dispense with it and this skb as well. */ -static int iptfs_input_ordered(struct gro_cells *gro_cells, - struct xfrm_state *x, struct sk_buff *skb) +static int iptfs_input_ordered(struct xfrm_state *x, struct sk_buff *skb) { u8 hbytes[sizeof(struct ipv6hdr)]; struct ip_iptfs_cc_hdr iptcch; @@ -1431,7 +1429,7 @@ static enum hrtimer_restart iptfs_drop_timer(struct hrtimer *me) pr_devinf("receiving ordered list of len %u\n", count); list_for_each_entry_safe (skb, next, &list, list) { skb_list_del_init(skb); - (void)iptfs_input_ordered(xfrm_input_gro_cells, x, skb); + (void)iptfs_input_ordered(x, skb); } } return HRTIMER_NORESTART; @@ -1440,8 +1438,7 @@ static enum hrtimer_restart iptfs_drop_timer(struct hrtimer *me) /* * We have an IPTFS payload order it if needed. */ -static int iptfs_input(struct gro_cells *gro_cells, struct xfrm_state *x, - struct sk_buff *skb) +static int iptfs_input(struct xfrm_state *x, struct sk_buff *skb) { struct list_head freelist, list; struct xfrm_iptfs_data *xtfs = x->mode_data; @@ -1450,7 +1447,7 @@ static int iptfs_input(struct gro_cells *gro_cells, struct xfrm_state *x, /* Fast path for no reorder window. */ if (xtfs->cfg.reorder_win_size == 0) { - iptfs_input_ordered(gro_cells, x, skb); + iptfs_input_ordered(x, skb); return 0; } @@ -1470,7 +1467,7 @@ static int iptfs_input(struct gro_cells *gro_cells, struct xfrm_state *x, pr_devinf("receiving ordered list of len %u\n", count); list_for_each_entry_safe (skb, next, &list, list) { skb_list_del_init(skb); - (void)iptfs_input_ordered(gro_cells, x, skb); + (void)iptfs_input_ordered(x, skb); } } @@ -2132,18 +2129,17 @@ static enum hrtimer_restart iptfs_delay_timer(struct hrtimer *me) iptfs_output_queued(x, &list); return HRTIMER_NORESTART; -}_ +} -_ static void iptfs_xmit_prep(struct xfrm_state *x, struct sk_buff *skb) { struct xfrm_offload *xo = xfrm_offload(skb); uint hsize; if (x->outer_mode.family == AF_INET) - hsize = sizeof(iphdr); + hsize = sizeof(struct iphdr); else if (x->outer_mode.family == AF_INET6) - hsize = sizeof(ipv6hdr); + hsize = sizeof(struct ipv6hdr); else return; @@ -2226,7 +2222,8 @@ static int iptfs_user_init(struct net *net, struct xfrm_state *x, static int iptfs_copy_to_user(struct xfrm_state *x, struct sk_buff *skb) { - struct xfrm_iptfs_config *xc = &x->mode_data->cfg; + struct xfrm_iptfs_data *xtfs = x->mode_data; + struct xfrm_iptfs_config *xc = &xtfs->cfg; int ret; pr_devinf("copy state to user %p\n", x->tfs_data); diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index af9305a2e98655..7ad2d791f5576c 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2692,7 +2692,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, dst1->input = dst_discard; - mode_cbs = xfrm_get_mode_cbs(xfrm[i]->props.mode); + mode_cbs = xfrm_get_mode_cbs(xfrm[i]->props.mode, false); if (mode_cbs && mode_cbs->output) dst1->output = mode_cbs->output; else { diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index e29e1c4d2654e4..8570990e5ad05b 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -523,22 +523,22 @@ static const struct xfrm_mode *xfrm_get_mode(unsigned int encap, int family) return NULL; } -static const struct xfrm_mode_cbs xfrm_mode_cbs_map[XFRM_MODE_MAX]; +static struct xfrm_mode_cbs xfrm_mode_cbs_map[XFRM_MODE_MAX]; -int xfrm_register_mode_cbs(const struct xfrm_mode_cbs *mode_cbs) +int xfrm_register_mode_cbs(u8 mode, const struct xfrm_mode_cbs *mode_cbs) { - if (mode_cbs->mode >= XFRM_MODE_MAX) + if (mode >= XFRM_MODE_MAX) return -EINVAL; - xfrm_mode_cbs[mode] = *mode_cbs; + xfrm_mode_cbs_map[mode] = *mode_cbs; return 0; } -void xfrm_unregister_mode_cbs(const struct xfrm_mode_cbs *mode_cbs) +void xfrm_unregister_mode_cbs(u8 mode) { - if (mode_cbs->mode < XFRM_MODE_MAX) - memset(&xfrm_mode_cbs_valid[mode], 0, - sizeof(xfrm_mode_cbs_valid[mode]); + if (mode < XFRM_MODE_MAX) + memset(&xfrm_mode_cbs_map[mode], 0, + sizeof(xfrm_mode_cbs_map[mode])); } const struct xfrm_mode_cbs *xfrm_get_mode_cbs(u8 mode, bool try_load) @@ -557,7 +557,7 @@ EXPORT_SYMBOL(xfrm_state_free); static void ___xfrm_state_destroy(struct xfrm_state *x) { - if (x->mode_cbs && x->mode_cbs->delete_state) { + if (x->mode_cbs && x->mode_cbs->delete_state) x->mode_cbs->delete_state(x); hrtimer_cancel(&x->mtimer); del_timer_sync(&x->rtimer); @@ -2824,7 +2824,6 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload, { const struct xfrm_mode *inner_mode; const struct xfrm_mode *outer_mode; - const struct xfrm_mode_cbs *mode_cbs; int family = x->props.family; int err; @@ -2896,7 +2895,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload, goto error; } - x->mode_cbs = xfrm_get_mode_cbs(x->props.mode); + x->mode_cbs = xfrm_get_mode_cbs(x->props.mode, false); if (x->mode_cbs && x->mode_cbs->create_state) { err = x->mode_cbs->create_state(x); if (err) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index f64e824bb2bd37..a2a177a2ed7273 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -781,8 +781,14 @@ static struct xfrm_state *xfrm_state_construct(struct net *net, } #if IS_ENABLED(CONFIG_XFRM_IPTFS) - if (x->props.mode == XFRM_MODE_IPTFS) - err = xfrm_iptfs_user_init(net, x, attrs); + if (x->props.mode == XFRM_MODE_IPTFS) { + const struct xfrm_mode_cbs *mode_cbs; + + mode_cbs = xfrm_get_mode_cbs(x->props.mode, false); + if (mode_cbs && mode_cbs->user_init) + err = mode_cbs->user_init(net, x, attrs); + // err = xfrm_iptfs_user_init(net, x, attrs); + } if (err) goto error; #endif @@ -1200,7 +1206,7 @@ static int copy_to_user_state_extra(struct xfrm_state *x, if (ret) goto out; } - mode_cbs = xfrm_get_mode_cbs(x->props.mode); + mode_cbs = xfrm_get_mode_cbs(x->props.mode, false); if (mode_cbs && mode_cbs->copy_to_user) ret = mode_cbs->copy_to_user(x, skb); if (ret)