>From 3d9ad9fab35f4efd6c2fb17853aaca986e7daaf3 Mon Sep 17 00:00:00 2001 From: Antony Antony Date: Thu, 16 Nov 2023 16:46:54 +0100 Subject: [PATCH] xfrm: iptfs extend xfrm_sa_len think this extension is necessary. I wonder how it works now:) May it is alreday handled:) Signed-off-by: Antony Antony --- include/net/xfrm.h | 1 + net/xfrm/xfrm_iptfs.c | 18 ++++++++++++++++++ net/xfrm/xfrm_user.c | 3 +++ 3 files changed, 22 insertions(+) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 176ab5ac436e..7ca508b0c46c 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -474,6 +474,7 @@ struct xfrm_mode_cbs { * mac_header should point at protocol/nexthdr of the outer IP */ int (*prepare_output)(struct xfrm_state *x, struct sk_buff *skb); + unsigned int (*xfrm_sa_len)(const struct xfrm_state *x); }; int xfrm_register_mode_cbs(u8 mode, const struct xfrm_mode_cbs *mode_cbs); diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c index 910c5e060931..d8b02cc3073b 100644 --- a/net/xfrm/xfrm_iptfs.c +++ b/net/xfrm/xfrm_iptfs.c @@ -2613,6 +2613,23 @@ static int iptfs_copy_to_user(struct xfrm_state *x, struct sk_buff *skb) return ret; } +static unsigned int iptfs_xfrm_sa_len(const struct xfrm_state *x) +{ + struct xfrm_iptfs_data *xtfs = x->mode_data; + struct xfrm_iptfs_config *xc = &xtfs->cfg; + unsigned int l = 0; + + if (xc->dont_frag) + l += nla_total_size(sizeof(xc->reorder_win_size)); + l += nla_total_size(sizeof(xc->reorder_win_size)); + l += nla_total_size(sizeof(xc->pkt_size)); + l += nla_total_size(sizeof(xc->max_queue_size)); + l += nla_total_size(sizeof(xc->drop_time_us)); + l += nla_total_size(sizeof(xc->init_delay_us)); + + return l; +} + static int iptfs_create_state(struct xfrm_state *x) { struct xfrm_iptfs_data *xtfs; @@ -2701,6 +2718,7 @@ static const struct xfrm_mode_cbs iptfs_mode_cbs = { .input = iptfs_input, .output = iptfs_output_collect, .prepare_output = iptfs_prepare_output, + .xfrm_sa_len = iptfs_xfrm_sa_len, }; static int __init xfrm_iptfs_init(void) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 4b0e462d5e31..737636b2c267 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -3350,6 +3350,9 @@ static inline unsigned int xfrm_sa_len(struct xfrm_state *x) if (x->mapping_maxage) l += nla_total_size(sizeof(x->mapping_maxage)); + if (x->mode_cbs && x->mode_cbs->copy_to_user) + l += x->mode_cbs->xfrm_sa_len(x); + return l; } -- 2.42.0