@@ -379,6 +379,8 @@ struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
struct ipv6_opt_hdr *newopt);
struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
struct ipv6_txoptions *opt);
+int ipv6_opt_update(struct sock *sk, struct ipv6_txoptions *opt,
+ int which, struct ipv6_opt_hdr *new);
/*
* Parsing tlv encoded headers.
@@ -118,6 +118,22 @@ struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
return opt;
}
+int ipv6_opt_update(struct sock *sk, struct ipv6_txoptions *opt,
+ int which, struct ipv6_opt_hdr *new)
+{
+ opt = ipv6_renew_options(sk, opt, which, new);
+ if (IS_ERR(opt))
+ return PTR_ERR(opt);
+
+ opt = ipv6_update_options(sk, opt);
+ if (opt) {
+ atomic_sub(opt->tot_len, &sk->sk_omem_alloc);
+ txopt_put(opt);
+ }
+
+ return 0;
+}
+
static bool setsockopt_needs_rtnl(int optname)
{
switch (optname) {
Add a utility function to replace socket's options with a new set. Signed-off-by: Tom Herbert <tom@quantonium.net> --- include/net/ipv6.h | 2 ++ net/ipv6/ipv6_sockglue.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)