Skip to content

Commit

Permalink
temp: get compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
choppsv1 committed Aug 6, 2023
1 parent 1e0cbf8 commit e9124f7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
6 changes: 3 additions & 3 deletions include/net/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 11 additions & 14 deletions net/xfrm/xfrm_iptfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion net/xfrm/xfrm_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 10 additions & 11 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e9124f7

Please sign in to comment.