ipv6: Extension header infrastructure
Subsystems (7)
v5 cover ipv6: Extension header infrastructure
This patchset improves the IPv6 extension header infrastructure to make extension headers more usable and scalable.
- Reorganize extension header files to separate out common API components
- Create common TLV handler that will can be used in other use cases (e.g. segment routing TLVs, UDP options)
- Allow registration of TLV handlers
- Elaborate on the TLV tables to include more characteristics
- Add a netlink interface to set TLV parameters (such as alignment requirements, authorization to send, etc.)
- Enhance validation of TLVs being sent. Validation is strict (unless overridden by admin) following that sending clause of the robustness principle
- Allow non-privileged users to set Hop-by-Hop and Destination Options if authorized by the admin
v2:
- Fix build errors from missing include file.
v3:
- Fix kbuild issue for ipv6_opt_hdr declared inside parameter list in ipeh.h
v4:
- Resubmit
v5:
- Fix reverse christmas tree issue
Tom Herbert (7):
ipeh: Create exthdrs_options.c and ipeh.h
ipeh: Move generic EH functions to exthdrs_common.c
ipeh: Generic TLV parser
ip6tlvs: Registration of TLV handlers and parameters
ip6tlvs: Add TX parameters
ip6tlvs: Add netlink interface
ip6tlvs: Validation of TX Destination and Hop-by-Hop options
include/net/ipeh.h | 208 ++++++++ include/net/ipv6.h | 12 +- include/uapi/linux/in6.h | 6 + include/uapi/linux/ipeh.h | 53 ++ net/dccp/ipv6.c | 2 +- net/ipv6/Kconfig | 4 + net/ipv6/Makefile | 3 +- net/ipv6/calipso.c | 6 +- net/ipv6/datagram.c | 51 +- net/ipv6/exthdrs.c | 505 ++----------------- net/ipv6/exthdrs_common.c | 1158 ++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/exthdrs_options.c | 342 +++++++++++++ net/ipv6/ipv6_sockglue.c | 39 +- net/ipv6/raw.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- net/ipv6/udp.c | 2 +- net/l2tp/l2tp_ip6.c | 2 +- net/sctp/ipv6.c | 2 +- 18 files changed, 1881 insertions(+), 518 deletions(-) create mode 100644 include/net/ipeh.h create mode 100644 include/uapi/linux/ipeh.h create mode 100644 net/ipv6/exthdrs_common.c create mode 100644 net/ipv6/exthdrs_options.c
Signature · 1 line
2.7.4
PATCH v5 1/7 ipeh: Create exthdrs_options.c and ipeh.h
From: Tom Herbert <[email protected]>
Create exthdrs_options.c to hold code related to specific Hop-by-Hop and Destination extension header options. Move related functions in exthdrs.c to the new file.
Create include net/ipeh.h to contain common definitions for IP extension headers.
--- include/net/ipeh.h | 22 +++++ include/net/ipv6.h | 1 + net/ipv6/Makefile | 2 +- net/ipv6/exthdrs.c | 204 --------------------------------------------- net/ipv6/exthdrs_options.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 225 insertions(+), 205 deletions(-) create mode 100644 include/net/ipeh.h create mode 100644 net/ipv6/exthdrs_options.c
include/net/ipeh.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _NET_IPEH_H +#define _NET_IPEH_H + +#include <linux/skbuff.h> + +/* +* Parsing tlv encoded headers. +* +* Parsing function "func" returns true, if parsing succeed +* and false, if it failed. +* It MUST NOT touch skb->h. +*/ +struct tlvtype_proc { +int type; +bool (*func)(struct sk_buff *skb,int offset); +}; + +extern const struct tlvtype_proc tlvprocdestopt_lst[]; +extern const struct tlvtype_proc tlvprochopopt_lst[]; + +#endif /* _NET_IPEH_H */
include/net/ipv6.h +1 -0
@@ -20,6 +20,7 @@#include <net/flow_dissector.h> #include <net/snmp.h> #include <net/netns/hash.h> +#include <net/ipeh.h> #define SIN6_LEN_RFC2133 24
net/ipv6/Makefile +1 -1
@@ -10,7 +10,7 @@ ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \ route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \ raw.o icmp.o mcast.o reassembly.o tcp_ipv6.o ping.o \ exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o \ - udp_offload.o seg6.o fib6_notifier.o + udp_offload.o seg6.o fib6_notifier.o exthdrs_options.o ipv6-offload := ip6_offload.o tcpv6_offload.o exthdrs_offload.o
net/ipv6/exthdrs.c +0 -204
228 lines not on this page · raw message
net/ipv6/exthdrs_options.c new file +201 -0
201 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 net-next 1/7] ipeh: Create exthdrs_options.c and ipeh.h
Quoted 10 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Create
exthdrs_options.cto hold code related to specific Hop-by-Hop and Destination extension header options. Move related functions inexthdrs.cto the new file.Create include
net/ipeh.hto contain common definitions for IP extension headers.Signed-off-by Tom Herbert <[email protected]>
Hi Tom,
I'm not entirely clear on the direction this patchset it going in - I assume its part of a larger journey - but in isolation this patch seems fine to me.
Re: [PATCH v5 net-next 1/7] ipeh: Create exthdrs_options.c and ipeh.h
Quoted 11 lines · Simon Horman
Quoted 9 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Create
exthdrs_options.cto hold code related to specific Hop-by-Hop and Destination extension header options. Move related functions inexthdrs.cto the new file.Create include
net/ipeh.hto contain common definitions for IP extension headers.
Quoted 7 lines
Quoted 1 line
Signed-off-by Tom Herbert <[email protected]>Hi Tom,
I'm not entirely clear on the direction this patchset it going in - I assume its part of a larger journey - but in isolation this patch seems fine to me.
Hi Simon,
Sorry for the delayed response.
The overall direction here is to make extension headers as well as TLVs more usable and better performance. This patch isolates extension headers and TLV processing as a common facility which will allow multiple uses (SR TLVs can use this, IPv4 DestOpt and HBH options, and potentially other use cases of TLVs). Also, this set allows non-privileged applications to set DO and HBH options with correct permissions per option type and also validates options are properly formed per some rules (for instance the length of an option being set by an application can be validated that it falls in a required range).
Future patch sets will allow setting specific HBH and DO options on a socket (as opposed to all or nothing currently done). Experimental options will be allowed following the same format used for TCP experimental options. I'd also like to add ability to parse options in flow dissector and probably a BPF helper for XDP.
Quoted 3 lines
Reviewed-by Simon Horman <[email protected]>
PATCH v5 2/7 ipeh: Move generic EH functions to exthdrs_common.c
In reply to Tom HerbertFrom: Tom Herbert <[email protected]>
Move generic functions in exthdrs.c to new exthdrs_common.c so that exthdrs.c only contains functions that are specific to IPv6 processing, and exthdrs_common.c contains functions that are generic. These functions include those that will be used with IPv4 extension headers. Generic extension header related functions are prefixed by ipeh_.
--- include/net/ipeh.h | 12 ++++ include/net/ipv6.h | 9 --- net/dccp/ipv6.c | 2 +- net/ipv6/Kconfig | 4 ++ net/ipv6/Makefile | 1 + net/ipv6/calipso.c | 6 +- net/ipv6/exthdrs.c | 138 -------------------------------------------- net/ipv6/exthdrs_common.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/ipv6_sockglue.c | 2 +- net/ipv6/raw.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- net/ipv6/udp.c | 2 +- net/l2tp/l2tp_ip6.c | 2 +- net/sctp/ipv6.c | 2 +- 14 files changed, 171 insertions(+), 157 deletions(-) create mode 100644 net/ipv6/exthdrs_common.c
include/net/ipeh.h +12 -0
@@ -19,4 +19,16 @@ struct tlvtype_proc {extern const struct tlvtype_proc tlvprocdestopt_lst[];extern const struct tlvtype_proc tlvprochopopt_lst[]; +struct ipv6_txoptions ; +struct ipv6_opt_hdr ; + +struct ipv6_txoptions *ipeh_dup_options (struct sock *sk, +struct ipv6_txoptions *opt); +struct ipv6_txoptions *ipeh_renew_options (struct sock *sk, +struct ipv6_txoptions *opt, +int newtype, +struct ipv6_opt_hdr *newopt); +struct ipv6_txoptions *ipeh_fixup_options (struct ipv6_txoptions *opt_space, +struct ipv6_txoptions *opt); +#endif /* _NET_IPEH_H */
include/net/ipv6.h +0 -9
@@ -429,15 +429,6 @@ int ip6_ra_control(struct sock *sk, int sel);int ipv6_parse_hopopts (struct sk_buff *skb); -struct ipv6_txoptions *ipv6_dup_options (struct sock *sk, -struct ipv6_txoptions *opt); -struct ipv6_txoptions *ipv6_renew_options (struct sock *sk, -struct ipv6_txoptions *opt, -int newtype, -struct ipv6_opt_hdr *newopt); -struct ipv6_txoptions *ipv6_fixup_options (struct ipv6_txoptions *opt_space, -struct ipv6_txoptions *opt); -bool ipv6_opt_accepted (const struct sock *sk,const struct sk_buff *skb,const struct inet6_skb_parm *opt); struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
net/dccp/ipv6.c +1 -1
@@ -515,7 +515,7 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,if (!opt) opt =rcu_dereference (np->opt);if (opt) { - opt =ipv6_dup_options (newsk, opt); + opt =ipeh_dup_options (newsk, opt);RCU_INIT_POINTER (newnp->opt, opt); }inet_csk (newsk)->icsk_ext_hdr_len =0 ;
net/ipv6/Kconfig +4 -0
@@ -3,9 +3,13 @@ # IPv6 configuration # +config EXTHDRS + bool + # IPv6 as module will cause a CRASH if you try to unload it menuconfig IPV6 tristate "The IPv6 protocol" + select EXTHDRS default y ---help--- Support for IP version 6 (IPv6).
net/ipv6/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_IPV6_SIT) += sit.o obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o obj-$(CONFIG_IPV6_GRE) += ip6_gre.o obj-$(CONFIG_IPV6_FOU) += fou6.o +obj-$(CONFIG_EXTHDRS) += exthdrs_common.o obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
net/ipv6/calipso.c +3 -3
@@ -785,7 +785,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop) {struct ipv6_txoptions *old =txopt_get (inet6_sk (sk)), *txopts; - txopts =ipv6_renew_options (sk, old,IPV6_HOPOPTS , hop); + txopts =ipeh_renew_options (sk, old,IPV6_HOPOPTS , hop);txopt_put (old);if (IS_ERR (txopts))return PTR_ERR (txopts);
@@ -1207,7 +1207,7 @@ static int calipso_req_setattr(struct request_sock *req,if (IS_ERR (new))return PTR_ERR (new); - txopts =ipv6_renew_options (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , new); + txopts =ipeh_renew_options (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , new);kfree (new);
@@ -1244,7 +1244,7 @@ static void calipso_req_delattr(struct request_sock *req)if (calipso_opt_del (req_inet->ipv6_opt->hopopt, &new))return ;/* Nothing to do */ - txopts =ipv6_renew_options (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , new); + txopts =ipeh_renew_options (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , new);if (!IS_ERR (txopts)) { txopts =xchg (&req_inet->ipv6_opt, txopts);
net/ipv6/exthdrs.c +0 -138
144 lines not on this page · raw message
net/ipv6/exthdrs_common.c new file +144 -0
144 lines not on this page · raw message
net/ipv6/ipv6_sockglue.c +1 -1
@@ -427,7 +427,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, opt =rcu_dereference_protected (np->opt,lockdep_sock_is_held (sk)); - opt =ipv6_renew_options (sk, opt, optname, new); + opt =ipeh_renew_options (sk, opt, optname, new);kfree (new);if (IS_ERR (opt)) { retv =PTR_ERR (opt);
net/ipv6/raw.c +1 -1
@@ -889,7 +889,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) }if (flowlabel) opt =fl6_merge_options (&opt_space, flowlabel, opt); - opt =ipv6_fixup_options (&opt_space, opt); + opt =ipeh_fixup_options (&opt_space, opt); fl6.flowi6_proto = proto; fl6.flowi6_mark = ipc6.sockc.mark;
net/ipv6/tcp_ipv6.c +1 -1
@@ -1249,7 +1249,7 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *if (!opt) opt =rcu_dereference (np->opt);if (opt) { - opt =ipv6_dup_options (newsk, opt); + opt =ipeh_dup_options (newsk, opt);RCU_INIT_POINTER (newnp->opt, opt); }inet_csk (newsk)->icsk_ext_hdr_len =0 ;
net/ipv6/udp.c +1 -1
@@ -1386,7 +1386,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) }if (flowlabel) opt =fl6_merge_options (&opt_space, flowlabel, opt); - opt =ipv6_fixup_options (&opt_space, opt); + opt =ipeh_fixup_options (&opt_space, opt); ipc6.opt = opt; fl6.flowi6_proto = sk->sk_protocol;
net/l2tp/l2tp_ip6.c +1 -1
@@ -590,7 +590,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) }if (flowlabel) opt =fl6_merge_options (&opt_space, flowlabel, opt); - opt =ipv6_fixup_options (&opt_space, opt); + opt =ipeh_fixup_options (&opt_space, opt); ipc6.opt = opt; fl6.flowi6_proto = sk->sk_protocol;
net/sctp/ipv6.c +1 -1
@@ -441,7 +441,7 @@ static void sctp_v6_copy_ip_options(struct sock *sk, struct sock *newsk)rcu_read_lock (); opt =rcu_dereference (np->opt);if (opt) { - opt =ipv6_dup_options (newsk, opt); + opt =ipeh_dup_options (newsk, opt);if (!opt)pr_err ("%s: Failed to copy ip options\n" , __func__); }
Signature · 1 line
2.7.4
Re: [PATCH v5 net-next 2/7] ipeh: Move generic EH functions to exthdrs_common.c
Quoted 9 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Move generic functions in
exthdrs.cto newexthdrs_common.cso thatexthdrs.conly contains functions that are specific to IPv6 processing, andexthdrs_common.ccontains functions that are generic. These functions include those that will be used with IPv4 extension headers. Generic extension header related functions are prefixed byipeh_.Signed-off-by Tom Herbert <[email protected]>
...
Quoted 21 lines
net/dccp/ipv6.c +1
-1@@ -515,7 +515,7 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,if (!opt) opt =rcu_dereference (np->opt);if (opt) { - opt =ipv6_dup_options (newsk, opt); + opt =ipeh_dup_options (newsk, opt);RCU_INIT_POINTER (newnp->opt, opt); }inet_csk (newsk)->icsk_ext_hdr_len =0 ;net/ipv6/Kconfig +0
-0@@ -3,9 +3,13 @@ # IPv6 configuration #
net/ipv6/Kconfig line 15
Quoted 10 lines
net/ipv6/Kconfig +4
-0+config EXTHDRS + bool + # IPv6 as module will cause a CRASH if you try to unload it menuconfig IPV6 tristate "The IPv6 protocol" + select EXTHDRS default y ---help--- Support for IP version 6 (IPv6).
Hi Tom,
could you expand on the motivation for this new Kconfig symbol. It seems that at this time exthdrs_common.o could simply depend on IPV6.
Otherwise this patch seems fine to me.
Quoted 12 lines
net/ipv6/Makefile +1
-0@@ -44,6 +44,7 @@ obj-$(CONFIG_IPV6_SIT) += sit.o obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o obj-$(CONFIG_IPV6_GRE) += ip6_gre.o obj-$(CONFIG_IPV6_FOU) += fou6.o +obj-$(CONFIG_EXTHDRS) += exthdrs_common.o obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
...
Re: [PATCH v5 net-next 2/7] ipeh: Move generic EH functions to exthdrs_common.c
Quoted 48 lines · Simon Horman
Quoted 9 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Move generic functions in
exthdrs.cto newexthdrs_common.cso thatexthdrs.conly contains functions that are specific to IPv6 processing, andexthdrs_common.ccontains functions that are generic. These functions include those that will be used with IPv4 extension headers. Generic extension header related functions are prefixed byipeh_.Signed-off-by Tom Herbert <[email protected]>...
Quoted 21 lines
net/dccp/ipv6.c +1
-1@@ -515,7 +515,7 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,if (!opt) opt =rcu_dereference (np->opt);if (opt) { - opt =ipv6_dup_options (newsk, opt); + opt =ipeh_dup_options (newsk, opt);RCU_INIT_POINTER (newnp->opt, opt); }inet_csk (newsk)->icsk_ext_hdr_len =0 ;net/ipv6/Kconfig +0
-0@@ -3,9 +3,13 @@ # IPv6 configuration #net/ipv6/Kconfig line 15
Quoted 10 lines
net/ipv6/Kconfig +4
-0+config EXTHDRS + bool + # IPv6 as module will cause a CRASH if you try to unload it menuconfig IPV6 tristate "The IPv6 protocol" + select EXTHDRS default y ---help--- Support for IP version 6 (IPv6).Hi Tom,
Quoted 3 lines
could you expand on the motivation for this new
Kconfigsymbol. It seems that at this time exthdrs_common.o could simply depend on IPV6.
It anticipates other uses cases of extension headers, in particular IPv4 extension headers
(https://tools.ietf.org/html/draft-herbert-ipv4-hbh-destopt-00)
Quoted 16 lines
Otherwise this patch seems fine to me.
Quoted 12 lines
net/ipv6/Makefile +1
-0@@ -44,6 +44,7 @@ obj-$(CONFIG_IPV6_SIT) += sit.o obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o obj-$(CONFIG_IPV6_GRE) += ip6_gre.o obj-$(CONFIG_IPV6_FOU) += fou6.o +obj-$(CONFIG_EXTHDRS) += exthdrs_common.o obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)...
Re: [PATCH v5 net-next 2/7] ipeh: Move generic EH functions to exthdrs_common.c
Quoted 49 lines · Tom Herbert
Quoted 48 lines · Simon Horman
Quoted 9 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Move generic functions in
exthdrs.cto newexthdrs_common.cso thatexthdrs.conly contains functions that are specific to IPv6 processing, andexthdrs_common.ccontains functions that are generic. These functions include those that will be used with IPv4 extension headers. Generic extension header related functions are prefixed byipeh_.Signed-off-by Tom Herbert <[email protected]>...
Quoted 21 lines
net/dccp/ipv6.c +1
-1@@ -515,7 +515,7 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,if (!opt) opt =rcu_dereference (np->opt);if (opt) { - opt =ipv6_dup_options (newsk, opt); + opt =ipeh_dup_options (newsk, opt);RCU_INIT_POINTER (newnp->opt, opt); }inet_csk (newsk)->icsk_ext_hdr_len =0 ;net/ipv6/Kconfig +0
-0@@ -3,9 +3,13 @@ # IPv6 configuration #net/ipv6/Kconfig line 15
Quoted 10 lines
net/ipv6/Kconfig +4
-0+config EXTHDRS + bool + # IPv6 as module will cause a CRASH if you try to unload it menuconfig IPV6 tristate "The IPv6 protocol" + select EXTHDRS default y ---help--- Support for IP version 6 (IPv6).Hi Tom,
Quoted 6 lines
Quoted 3 lines
could you expand on the motivation for this new
Kconfigsymbol. It seems that at this time exthdrs_common.o could simply depend on IPV6.It anticipates other uses cases of extension headers, in particular IPv4 extension headers
(https://tools.ietf.org/html/draft-herbert-ipv4-hbh-destopt-00)
Thanks Tom,
I would lean towards adding the new Kconfig option when it is needed, but I don't feel strongly aout this.
Quoted 17 lines
Quoted 16 lines
Otherwise this patch seems fine to me.
Quoted 12 lines
net/ipv6/Makefile +1
-0@@ -44,6 +44,7 @@ obj-$(CONFIG_IPV6_SIT) += sit.o obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o obj-$(CONFIG_IPV6_GRE) += ip6_gre.o obj-$(CONFIG_IPV6_FOU) += fou6.o +obj-$(CONFIG_EXTHDRS) += exthdrs_common.o obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)...
PATCH v5 3/7 ipeh: Generic TLV parser
In reply to Tom HerbertFrom: Tom Herbert <[email protected]>
Create a generic TLV parser. This will be used with various extension headers that carry options including Destination, Hop-by-Hop, Segment Routing TLVs, and other cases of simple stateless parsing.
--- include/net/ipeh.h | 25 ++++++++ net/ipv6/exthdrs.c | 159 +++++++++++----------------------------------- net/ipv6/exthdrs_common.c | 114 +++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 121 deletions(-)
include/net/ipeh.h +25 -0
@@ -31,4 +31,29 @@ struct ipv6_txoptions *ipeh_renew_options(struct sock *sk,struct ipv6_txoptions *ipeh_fixup_options (struct ipv6_txoptions *opt_space,struct ipv6_txoptions *opt); +/* Generic extension header TLV parser */ + +enum ipeh_parse_errors { +IPEH_PARSE_ERR_PAD1 ,/* Excessive PAD1 */ +IPEH_PARSE_ERR_PADN ,/* Excessive PADN */ +IPEH_PARSE_ERR_PADNZ ,/* Non-zero padding data */ +IPEH_PARSE_ERR_EH_TOOBIG ,/* Length of EH exceeds limit */ +IPEH_PARSE_ERR_OPT_TOOBIG ,/* Option size exceeds limit */ +IPEH_PARSE_ERR_OPT_TOOMANY ,/* Option count exceeds limit */ +IPEH_PARSE_ERR_OPT_UNK_DISALW ,/* Unknown option disallowed */ +IPEH_PARSE_ERR_OPT_UNK ,/* Unknown option */ +}; + +/* The generic TLV parser assumes that the type value of PAD1 is 0, and PADN +* is 1. This is true for Destination, Hop-by-Hop and current definition +* of Segment Routing TLVs. +*/ +#define IPEH_TLV_PAD1 0 +#define IPEH_TLV_PADN 1 + +bool ipeh_parse_tlv (const struct tlvtype_proc *procs,struct sk_buff *skb, +int max_count,int off,int len, +bool (*parse_error)(struct sk_buff *skb, +int off,enum ipeh_parse_errors error)); +#endif /* _NET_IPEH_H */
net/ipv6/exthdrs.c +38 -121
189 lines not on this page · raw message
net/ipv6/exthdrs_common.c +114 -0
117 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 net-next 3/7] ipeh: Generic TLV parser
Quoted 38 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Create a generic TLV parser. This will be used with various extension headers that carry options including Destination, Hop-by-Hop, Segment Routing TLVs, and other cases of simple stateless parsing.
Signed-off-by Tom Herbert <[email protected]>--- include/net/ipeh.h | 25 ++++++++ net/ipv6/exthdrs.c | 159 +++++++++++----------------------------------- net/ipv6/exthdrs_common.c | 114 +++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 121 deletions(-)include/net/ipeh.h +16
-0@@ -31,4 +31,29 @@ struct ipv6_txoptions *ipeh_renew_options(struct sock *sk,struct ipv6_txoptions *ipeh_fixup_options (struct ipv6_txoptions *opt_space,struct ipv6_txoptions *opt); +/* Generic extension header TLV parser */ + +enum ipeh_parse_errors { +IPEH_PARSE_ERR_PAD1 ,/* Excessive PAD1 */ +IPEH_PARSE_ERR_PADN ,/* Excessive PADN */ +IPEH_PARSE_ERR_PADNZ ,/* Non-zero padding data */ +IPEH_PARSE_ERR_EH_TOOBIG ,/* Length of EH exceeds limit */ +IPEH_PARSE_ERR_OPT_TOOBIG ,/* Option size exceeds limit */ +IPEH_PARSE_ERR_OPT_TOOMANY ,/* Option count exceeds limit */ +IPEH_PARSE_ERR_OPT_UNK_DISALW ,/* Unknown option disallowed */ +IPEH_PARSE_ERR_OPT_UNK ,/* Unknown option */ +}; + +/* The generic TLV parser assumes that the type value of PAD1 is 0, and PADN +* is 1. This is true for Destination, Hop-by-Hop and current definition +* of Segment Routing TLVs.
include/net/ipeh.h struct ipv6_txoptions *ipeh_renew_options(struct sock *sk, · line 59
Quoted 10 lines
include/net/ipeh.h +9
-0+*/ +#define IPEH_TLV_PAD1 0 +#define IPEH_TLV_PADN 1 + +bool ipeh_parse_tlv (const struct tlvtype_proc *procs,struct sk_buff *skb, +int max_count,int off,int len, +bool (*parse_error)(struct sk_buff *skb, +int off,enum ipeh_parse_errors error)); +#endif /* _NET_IPEH_H */
Hi Tom,
Unless I misread things, which is entirely possible, it seems as well as moving code around this patch changes behaviour under some error conditions via the parse_error callback and the ipv6_parse_error() implementation of it below.
I think such a change is worth of at lest calling out in the changelog and perhaps braking out into a separate patch.
...
Re: [PATCH v5 net-next 3/7] ipeh: Generic TLV parser
Quoted 53 lines · Simon Horman
Quoted 38 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Create a generic TLV parser. This will be used with various extension headers that carry options including Destination, Hop-by-Hop, Segment Routing TLVs, and other cases of simple stateless parsing.
Signed-off-by Tom Herbert <[email protected]>--- include/net/ipeh.h | 25 ++++++++ net/ipv6/exthdrs.c | 159 +++++++++++----------------------------------- net/ipv6/exthdrs_common.c | 114 +++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 121 deletions(-)include/net/ipeh.h +16
-0@@ -31,4 +31,29 @@ struct ipv6_txoptions *ipeh_renew_options(struct sock *sk,struct ipv6_txoptions *ipeh_fixup_options (struct ipv6_txoptions *opt_space,struct ipv6_txoptions *opt); +/* Generic extension header TLV parser */ + +enum ipeh_parse_errors { +IPEH_PARSE_ERR_PAD1 ,/* Excessive PAD1 */ +IPEH_PARSE_ERR_PADN ,/* Excessive PADN */ +IPEH_PARSE_ERR_PADNZ ,/* Non-zero padding data */ +IPEH_PARSE_ERR_EH_TOOBIG ,/* Length of EH exceeds limit */ +IPEH_PARSE_ERR_OPT_TOOBIG ,/* Option size exceeds limit */ +IPEH_PARSE_ERR_OPT_TOOMANY ,/* Option count exceeds limit */ +IPEH_PARSE_ERR_OPT_UNK_DISALW ,/* Unknown option disallowed */ +IPEH_PARSE_ERR_OPT_UNK ,/* Unknown option */ +}; + +/* The generic TLV parser assumes that the type value of PAD1 is 0, and PADN +* is 1. This is true for Destination, Hop-by-Hop and current definition +* of Segment Routing TLVs. include/net/ipeh.h struct ipv6_txoptions *ipeh_renew_options(struct sock *sk, · line 59
Quoted 10 lines
include/net/ipeh.h +9
-0+*/ +#define IPEH_TLV_PAD1 0 +#define IPEH_TLV_PADN 1 + +bool ipeh_parse_tlv (const struct tlvtype_proc *procs,struct sk_buff *skb, +int max_count,int off,int len, +bool (*parse_error)(struct sk_buff *skb, +int off,enum ipeh_parse_errors error)); +#endif /* _NET_IPEH_H */ Hi Tom,
Quoted 8 lines
Unless I misread things, which is entirely possible, it seems as well as moving code around this patch changes behaviour under some error conditions via the
parse_errorcallback and theipv6_parse_error()implementation of it below.I think such a change is worth of at lest calling out in the changelog and perhaps braking out into a separate patch.
Okay, makes sense to split out the parse_error code. I also noticed that there's no counter being bumped when we drop a HBH option, I'll fix that.
Quoted 1 line
...
PATCH v5 4/7 ip6tlvs: Registration of TLV handlers and parameters
In reply to Tom HerbertFrom: Tom Herbert <[email protected]>
Create a single TLV parameter table that holds meta information for IPv6 Hop-by-Hop and Destination TLVs. The data structure is composed of a 256 element array of u8's (one entry for each TLV type to allow O(1) lookup). Each entry provides an offset into an array of TLV proc data structures which follows the array of u8s. The TLV proc data structure contains parameters and handler functions for receiving and transmitting TLVs. The zeroth element in the TLV proc array provides default parameters for TLVs.
A class attribute indicates the type of extension header in which the TLV may be used (e.g. Hop-by-Hop options, Destination options, or Destination options before the routing header).
Functions are defined to manipulate entries in the TLV parameter table.
* tlv_{set|unset}_proc set a TLV proc entry (ops and parameters)
* tlv_{set|unset}_params set parameters only
Receive TLV lookup and processing is modified to be a lookup in the TLV parameter table. An init table containing parameters for TLVs supported by the kernel is used to initialize the TLV table.
--- include/net/ipeh.h | 107 ++++++++++++++++-- include/net/ipv6.h | 3 + include/uapi/linux/ipeh.h | 16 +++ net/ipv6/exthdrs.c | 14 ++- net/ipv6/exthdrs_common.c | 271 +++++++++++++++++++++++++++++++++++++++++---- net/ipv6/exthdrs_options.c | 63 +++++++---- 6 files changed, 421 insertions(+), 53 deletions(-) create mode 100644 include/uapi/linux/ipeh.h
include/net/ipeh.h +100 -7
@@ -11,13 +11,105 @@* and false, if it failed. * It MUST NOT touch skb->h. */ -struct tlvtype_proc { -int type; -bool (*func)(struct sk_buff *skb,int offset); +struct tlv_ops { +bool (*func)(unsigned int class,struct sk_buff *skb,int offset); }; -extern const struct tlvtype_proc tlvprocdestopt_lst[]; -extern const struct tlvtype_proc tlvprochopopt_lst[]; +struct tlv_rx_params { +unsigned char class :4 ; +}; + +struct tlv_tx_params { +}; + +struct tlv_params { +struct tlv_rx_params r; +struct tlv_tx_params t; +}; + +struct tlv_proc { +struct tlv_ops ops; +struct tlv_params params; +}; + +struct tlv_type { +struct tlv_proc proc; +}; + +struct tlv_proc_init { +int type; +struct tlv_proc proc; +}; + +struct tlv_param_table_data { +unsigned char entries[256 ]; +unsigned char count; +struct rcu_head rcu; +struct tlv_type types[0 ]; +}; + +struct tlv_param_table { +struct tlv_param_table_data __rcu *data; +}; + +extern struct tlv_param_table ipv6_tlv_param_table; + +int __ipeh_tlv_set (struct tlv_param_table *tlv_param_table, +unsigned char type,const struct tlv_params *params, +const struct tlv_ops *ops); + +static inline int ipeh_tlv_set_params (struct tlv_param_table *tlv_param_table, +unsigned char type, +const struct tlv_params *params) +{ +return __ipeh_tlv_set (tlv_param_table, type, params,NULL ); +} + +static inline int ipeh_tlv_set_proc (struct tlv_param_table *tlv_param_table, +unsigned char type, +const struct tlv_proc *proc) +{ +return __ipeh_tlv_set (tlv_param_table, type, + &proc->params, &proc->ops); +} + +int __ipeh_tlv_unset (struct tlv_param_table *tlv_param_table, +unsigned char type,bool params_only); + +static inline int ipeh_tlv_unset_params (struct tlv_param_table *tlv_param_table, +unsigned char type) +{ +return __ipeh_tlv_unset (tlv_param_table, type, true); +} + +static inline int ipeh_tlv_unset_proc (struct tlv_param_table *tlv_param_table, +unsigned char type) +{ +return __ipeh_tlv_unset (tlv_param_table, type, false); +} + +/* ipeh_tlv_get_proc_by_type assumes rcu_read_lock is held */ +static inline struct tlv_proc *ipeh_tlv_get_proc_by_type ( +struct tlv_param_table *tlv_param_table,unsigned char type) +{ +struct tlv_param_table_data *tpt = +rcu_dereference (tlv_param_table->data); + +return &tpt->types[tpt->entries[type]].proc; +} + +/* ipeh_tlv_get_proc assumes rcu_read_lock is held */ +static inline struct tlv_proc *ipeh_tlv_get_proc ( +struct tlv_param_table *tlv_param_table, +const __u8 *tlv) +{ +return ipeh_tlv_get_proc_by_type (tlv_param_table, tlv[0 ]); +} + +int ipeh_exthdrs_init (struct tlv_param_table *tlv_param_table, +const struct tlv_proc_init *init_params, +int num_init_params); +void ipeh_exthdrs_fini (struct tlv_param_table *tlv_param_table);struct ipv6_txoptions ;struct ipv6_opt_hdr ;
@@ -51,8 +143,9 @@ enum ipeh_parse_errors {#define IPEH_TLV_PAD1 0#define IPEH_TLV_PADN 1 -bool ipeh_parse_tlv (const struct tlvtype_proc *procs,struct sk_buff *skb, -int max_count,int off,int len, +bool ipeh_parse_tlv (unsigned int class, +struct tlv_param_table *tlv_param_table, +struct sk_buff *skb,int max_count,int off,int len,bool (*parse_error)(struct sk_buff *skb,int off,enum ipeh_parse_errors error));
include/net/ipv6.h +3 -0
@@ -429,6 +429,9 @@ int ip6_ra_control(struct sock *sk, int sel);int ipv6_parse_hopopts (struct sk_buff *skb); +int ipv6_exthdrs_options_init (void ); +void ipv6_exthdrs_options_exit (void ); +bool ipv6_opt_accepted (const struct sock *sk,const struct sk_buff *skb,const struct inet6_skb_parm *opt); struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
include/uapi/linux/ipeh.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* ipeh.h - IP extension header TLV management */ + +#ifndef _UAPI_LINUX_IPEH_H +#define _UAPI_LINUX_IPEH_H + +/* Flags for EH type that can use a TLV option */ +#define IPEH_TLV_CLASS_FLAG_HOPOPT BIT(0) +#define IPEH_TLV_CLASS_FLAG_RTRDSTOPT BIT(1) +#define IPEH_TLV_CLASS_FLAG_DSTOPT BIT(2) + +#define IPEH_TLV_CLASS_FLAG_MASK (IPEH_TLV_CLASS_FLAG_HOPOPT | \ + IPEH_TLV_CLASS_FLAG_RTRDSTOPT | \ + IPEH_TLV_CLASS_FLAG_DSTOPT) + +#endif /* _UAPI_LINUX_IPEH_H */
net/ipv6/exthdrs.c +11 -3
@@ -47,6 +47,7 @@#ifdef CONFIG_IPV6_SEG6_HMAC #include <net/seg6_hmac.h> #endif +#include <uapi/linux/ipeh.h> #include <linux/uaccess.h>
@@ -131,7 +132,8 @@ static int ipv6_destopt_rcv(struct sk_buff *skb) dstbuf = opt->dst1;#endif -if (ipeh_parse_tlv (tlvprocdestopt_lst, skb, +if (ipeh_parse_tlv (IPEH_TLV_CLASS_FLAG_DSTOPT , + &ipv6_tlv_param_table, skb, init_net.ipv6.sysctl.max_dst_opts_cnt,2 , extlen -2 , ipv6_parse_error)) { skb->transport_header += extlen;
@@ -514,8 +516,13 @@ int __init ipv6_exthdrs_init(void)if (ret) goto out_destopt; + ret =ipv6_exthdrs_options_init (); +if (ret) + goto out_nodata; out:return ret; +out_nodata: +inet6_del_protocol (&nodata_protocol,IPPROTO_NONE ); out_destopt:inet6_del_protocol (&destopt_protocol,IPPROTO_DSTOPTS ); out_rthdr:
@@ -525,6 +532,7 @@ int __init ipv6_exthdrs_init(void)void ipv6_exthdrs_exit (void ) { +ipv6_exthdrs_options_exit ();inet6_del_protocol (&nodata_protocol,IPPROTO_NONE );inet6_del_protocol (&destopt_protocol,IPPROTO_DSTOPTS );inet6_del_protocol (&rthdr_protocol,IPPROTO_ROUTING );
@@ -555,8 +563,8 @@ int ipv6_parse_hopopts(struct sk_buff *skb) goto fail_and_free; opt->flags |=IP6SKB_HOPBYHOP ; -if (ipeh_parse_tlv (tlvprochopopt_lst, skb, - init_net.ipv6.sysctl.max_hbh_opts_cnt, +if (ipeh_parse_tlv (IPEH_TLV_CLASS_FLAG_HOPOPT , &ipv6_tlv_param_table, + skb, init_net.ipv6.sysctl.max_hbh_opts_cnt,2 , extlen -2 , ipv6_parse_error)) { skb->transport_header += extlen; opt =IP6CB (skb);
net/ipv6/exthdrs_common.c +250 -21
314 lines not on this page · raw message
net/ipv6/exthdrs_options.c +41 -22
107 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 net-next 4/7] ip6tlvs: Registration of TLV handlers and parameters
Quoted 11 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Create a single TLV parameter table that holds meta information for IPv6 Hop-by-Hop and Destination TLVs. The data structure is composed of a 256 element array of u8's (one entry for each TLV type to allow O(1) lookup). Each entry provides an offset into an array of TLV proc data structures which follows the array of u8s. The TLV proc data structure contains parameters and handler functions for receiving and transmitting TLVs. The zeroth element in the TLV proc array provides default parameters for TLVs.
Quoted 8 lines
A class attribute indicates the type of extension header in which the TLV may be used (e.g. Hop-by-Hop options, Destination options, or Destination options before the routing header).
Functions are defined to manipulate entries in the TLV parameter table.
* tlv_{set|unset}_proc set a TLV proc entry (ops and parameters)
* tlv_{set|unset}_params set parameters only
Perhaps it would be worth mentioning that these will be used by a following patch in the series.
Quoted 5 lines
Receive TLV lookup and processing is modified to be a lookup in the TLV parameter table. An init table containing parameters for TLVs supported by the kernel is used to initialize the TLV table.
Signed-off-by Tom Herbert <[email protected]>
Minor nit about types below, but overall this looks good to me.
...
Quoted 4 lines
include/net/ipeh.h +0
-0
...
Quoted 6 lines
include/net/ipeh.h +6
-0+/* ipeh_tlv_get_proc_by_type assumes rcu_read_lock is held */ +static inline struct tlv_proc *ipeh_tlv_get_proc_by_type ( +struct tlv_param_table *tlv_param_table,unsigned char type) +{ +struct tlv_param_table_data *tpt = +rcu_dereference (tlv_param_table->data);
include/net/ipeh.h line 106
Quoted 10 lines
include/net/ipeh.h +10
-0+ +return &tpt->types[tpt->entries[type]].proc; +} + +/* ipeh_tlv_get_proc assumes rcu_read_lock is held */ +static inline struct tlv_proc *ipeh_tlv_get_proc ( +struct tlv_param_table *tlv_param_table, +const __u8 *tlv) +{ +return ipeh_tlv_get_proc_by_type (tlv_param_table, tlv[0 ]);
The type of tlv is const __u8 *, however,
1. the type of the 'type' parameter of ipeh_tlv_get_proc_by_type is unsigned char; and
2. this function is passed a value of type const unsigned char * by ipeh_parse_tlv().
I understand these are all one byte unsigned integer types. But perhaps this could be made more consistent somehow.
Quoted 1 line
+}
...
Quoted 4 lines
net/ipv6/exthdrs_common.c +0
-0
..
Quoted 38 lines
net/ipv6/exthdrs_common.c +11
-15@@ -221,26 +226,22 @@ bool ipeh_parse_tlv(const struct tlvtype_proc *procs, struct sk_buff *skb, tlv_count++;if (tlv_count > max_count && -parse_error (skb, off,IPEH_PARSE_ERR_OPT_TOOMANY )) + !parse_error (skb, off,IPEH_PARSE_ERR_OPT_TOOMANY )) goto bad; -for (curr = procs; curr->type >=0 ; curr++) { -if (curr->type == nh[off]) { -/* type specific length/alignment -* checks will be performed in the -* func(). -*/ -if (curr->func (skb, off) == false) -return false; -break ; - } - } -if (curr->type <0 && - !parse_error (skb, off, + curr =ipeh_tlv_get_proc (tlv_param_table, &nh[off]); +if ((curr->params.r.class & class) && curr->ops.func) { +/* Handler will apply additional checks to +* the TLV +*/ +if (!curr->ops.func (class, skb, off)) +return false; + }else if (!parse_error (skb, off, disallow_unknowns ?IPEH_PARSE_ERR_OPT_UNK_DISALW : -IPEH_PARSE_ERR_OPT_UNK )) +IPEH_PARSE_ERR_OPT_UNK )) { goto bad; + } padlen =0 ;break ;
PATCH v5 5/7 ip6tlvs: Add TX parameters
In reply to Tom HerbertFrom: Tom Herbert <[email protected]>
Define a number of transmit parameters for TLV Parameter table definitions. These will be used for validating TLVs that are set on a socket.
--- include/net/ipeh.h | 18 ++++++++++++++++ include/uapi/linux/ipeh.h | 8 +++++++ net/ipv6/exthdrs_common.c | 53 +++++++++++++++++++++++++++++++++++++++++++++- net/ipv6/exthdrs_options.c | 45 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 1 deletion(-)
include/net/ipeh.h +18 -0
@@ -20,6 +20,17 @@ struct tlv_rx_params { };struct tlv_tx_params { +unsigned char admin_perm :2 ; +unsigned char user_perm :2 ; +unsigned char class :3 ; +unsigned char rsvd :1 ; +unsigned char align_mult :4 ; +unsigned char align_off :4 ; +unsigned char data_len_mult :4 ; +unsigned char data_len_off :4 ; +unsigned char min_data_len; +unsigned char max_data_len; +unsigned short preferred_order; };struct tlv_params {
@@ -54,6 +65,13 @@ struct tlv_param_table {extern struct tlv_param_table ipv6_tlv_param_table; +/* Preferred TLV ordering for HBH and Dest options (placed by increasing order) +*/ +#define IPEH_TLV_PREF_ORDER_HAO 10 +#define IPEH_TLV_PREF_ORDER_ROUTERALERT 20 +#define IPEH_TLV_PREF_ORDER_JUMBO 30 +#define IPEH_TLV_PREF_ORDER_CALIPSO 40 +int __ipeh_tlv_set (struct tlv_param_table *tlv_param_table,unsigned char type,const struct tlv_params *params,const struct tlv_ops *ops);
include/uapi/linux/ipeh.h +8 -0
@@ -13,4 +13,12 @@ IPEH_TLV_CLASS_FLAG_RTRDSTOPT | \ IPEH_TLV_CLASS_FLAG_DSTOPT) +/* TLV permissions values */ +enum { +IPEH_TLV_PERM_NONE , +IPEH_TLV_PERM_WITH_CHECK , +IPEH_TLV_PERM_NO_CHECK , +IPEH_TLV_PERM_MAX =IPEH_TLV_PERM_NO_CHECK +}; +#endif /* _UAPI_LINUX_IPEH_H */
net/ipv6/exthdrs_common.c +52 -1
93 lines not on this page · raw message
net/ipv6/exthdrs_options.c +45 -0
69 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 net-next 5/7] ip6tlvs: Add TX parameters
Quoted 18 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Define a number of transmit parameters for TLV Parameter table definitions. These will be used for validating TLVs that are set on a socket.
Signed-off-by Tom Herbert <[email protected]>--- include/net/ipeh.h | 18 ++++++++++++++++ include/uapi/linux/ipeh.h | 8 +++++++ net/ipv6/exthdrs_common.c | 53 +++++++++++++++++++++++++++++++++++++++++++++- net/ipv6/exthdrs_options.c | 45 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 1 deletion(-)include/net/ipeh.h +0
-0
...
include/net/ipeh.h struct tlv_param_table { · line 74
Quoted 11 lines
include/net/ipeh.h +7
-0@@ -54,6 +65,13 @@ struct tlv_param_table {extern struct tlv_param_table ipv6_tlv_param_table; +/* Preferred TLV ordering for HBH and Dest options (placed by increasing order) +*/ +#define IPEH_TLV_PREF_ORDER_HAO 10 +#define IPEH_TLV_PREF_ORDER_ROUTERALERT 20 +#define IPEH_TLV_PREF_ORDER_JUMBO 30 +#define IPEH_TLV_PREF_ORDER_CALIPSO 40 +
Hi Tom,
Could you expand on why thse values were chosen?
I can see that this patch implements a specific use of
the 255 indexes available. But its not at all clear to me that this use fits expected use-cases (because I don't know what they are).
...
Re: [PATCH v5 net-next 5/7] ip6tlvs: Add TX parameters
Quoted 37 lines · Simon Horman
Quoted 18 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Define a number of transmit parameters for TLV Parameter table definitions. These will be used for validating TLVs that are set on a socket.
Signed-off-by Tom Herbert <[email protected]>--- include/net/ipeh.h | 18 ++++++++++++++++ include/uapi/linux/ipeh.h | 8 +++++++ net/ipv6/exthdrs_common.c | 53 +++++++++++++++++++++++++++++++++++++++++++++- net/ipv6/exthdrs_options.c | 45 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 1 deletion(-)include/net/ipeh.h +0
-0...
include/net/ipeh.h struct tlv_param_table { · line 74
Quoted 11 lines
include/net/ipeh.h +7
-0@@ -54,6 +65,13 @@ struct tlv_param_table {extern struct tlv_param_table ipv6_tlv_param_table; +/* Preferred TLV ordering for HBH and Dest options (placed by increasing order) +*/ +#define IPEH_TLV_PREF_ORDER_HAO 10 +#define IPEH_TLV_PREF_ORDER_ROUTERALERT 20 +#define IPEH_TLV_PREF_ORDER_JUMBO 30 +#define IPEH_TLV_PREF_ORDER_CALIPSO 40 +Hi Tom,
Quoted 2 lines
Could you expand on why thse values were chosen?
Pseudo random selection :-). The idea of having an ordering is to constrain the use of TLVs (in some environments there may be TLV ordering requirements or optimizations around specific ordering). Note that the ordering only applies to validation of TLVs being set to send, there are no ordering constraints in RX. Also, in the next patch set where application can set individual HBH and DO options on a socket, the ordering attribute is used to always produce the same order on the wire regardless of the ordering that the application set the options. For non-priviledeged applications especially, I believe it's good to be conservative and apply reasonable constraints such as ordering for TX (i.e. follow robustness principle).
Quoted 4 lines
I can see that this patch implements a specific use of
the 255 indexes available. But its not at all clear to me that this use fits expected use-cases (because I don't know what they are).
There are at more 253 non-padding option types. Fortunately the protocol designers had the foresight to limit option type to a byte and so it's reasonable to represent for lookup in simple arrays. Two bytes for type would have been much more painful (compare lookup on EtherType to IP protocol numbers for instance).
Quoted 1 line
...
PATCH v5 6/7 ip6tlvs: Add netlink interface
In reply to Tom HerbertFrom: Tom Herbert <[email protected]>
Add a netlink interface to manage the TX TLV parameters. Managed parameters include those for validating and sending TLVs being sent such as alignment, TLV ordering, length limits, etc.
--- include/net/ipeh.h | 16 +++ include/net/ipv6.h | 1 + include/uapi/linux/in6.h | 6 ++ include/uapi/linux/ipeh.h | 29 ++++++ net/ipv6/exthdrs_common.c | 238 +++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/exthdrs_options.c | 81 ++++++++++++++- 6 files changed, 369 insertions(+), 2 deletions(-)
include/net/ipeh.h +16 -0
@@ -3,6 +3,7 @@#define _NET_IPEH_H#include <linux/skbuff.h> +#include <net/genetlink.h> /* * Parsing tlv encoded headers.
@@ -106,6 +107,21 @@ static inline int ipeh_tlv_unset_proc(struct tlv_param_table *tlv_param_table,return __ipeh_tlv_unset (tlv_param_table, type, false); } +extern const struct nla_policy ipeh_tlv_nl_policy[]; + +int ipeh_tlv_nl_cmd_set (struct tlv_param_table *tlv_param_table, +struct genl_family *tlv_nl_family, +struct sk_buff *skb,struct genl_info *info); +int ipeh_tlv_nl_cmd_unset (struct tlv_param_table *tlv_param_table, +struct genl_family *tlv_nl_family, +struct sk_buff *skb,struct genl_info *info); +int ipeh_tlv_nl_cmd_get (struct tlv_param_table *tlv_param_table, +struct genl_family *tlv_nl_family, +struct sk_buff *skb,struct genl_info *info); +int ipeh_tlv_nl_dump (struct tlv_param_table *tlv_param_table, +struct genl_family *tlv_nl_family, +struct sk_buff *skb,struct netlink_callback *cb); +/* ipeh_tlv_get_proc_by_type assumes rcu_read_lock is held */ static inline struct tlv_proc *ipeh_tlv_get_proc_by_type (struct tlv_param_table *tlv_param_table,unsigned char type)
include/net/ipv6.h +1 -0
@@ -14,6 +14,7 @@#include <linux/jhash.h> #include <linux/refcount.h> #include <linux/jump_label_ratelimit.h> +#include <net/genetlink.h> #include <net/if_inet6.h> #include <net/ndisc.h> #include <net/flow.h>
include/uapi/linux/in6.h +6 -0
@@ -297,4 +297,10 @@ struct in6_flowlabel_req {* ... * MRT6_MAX */ + +/* NETLINK_GENERIC related info for IPv6 TLVs */ + +#define IPV6_TLV_GENL_NAME "ipv6-tlv" +#define IPV6_TLV_GENL_VERSION 0x1 +#endif /* _UAPI_LINUX_IN6_H */
include/uapi/linux/ipeh.h +29 -0
@@ -21,4 +21,33 @@ enum {IPEH_TLV_PERM_MAX =IPEH_TLV_PERM_NO_CHECK }; +/* NETLINK_GENERIC related info for IP TLVs */ + +enum { +IPEH_TLV_ATTR_UNSPEC , +IPEH_TLV_ATTR_TYPE ,/* u8, > 1 */ +IPEH_TLV_ATTR_ORDER ,/* u16 */ +IPEH_TLV_ATTR_ADMIN_PERM ,/* u8, perm value */ +IPEH_TLV_ATTR_USER_PERM ,/* u8, perm value */ +IPEH_TLV_ATTR_CLASS ,/* u8, 3 bit flags */ +IPEH_TLV_ATTR_ALIGN_MULT ,/* u8, 1 to 16 */ +IPEH_TLV_ATTR_ALIGN_OFF ,/* u8, 0 to 15 */ +IPEH_TLV_ATTR_MIN_DATA_LEN ,/* u8 (option data length) */ +IPEH_TLV_ATTR_MAX_DATA_LEN ,/* u8 (option data length) */ +IPEH_TLV_ATTR_DATA_LEN_MULT ,/* u8, 1 to 16 */ +IPEH_TLV_ATTR_DATA_LEN_OFF ,/* u8, 0 to 15 */ + + __IPEH_TLV_ATTR_MAX, +}; + +#define IPEH_TLV_ATTR_MAX (__IPEH_TLV_ATTR_MAX - 1) + +enum { +IPEH_TLV_CMD_SET , +IPEH_TLV_CMD_UNSET , +IPEH_TLV_CMD_GET , + + __IPEH_TLV_CMD_MAX, +}; +#endif /* _UAPI_LINUX_IPEH_H */
net/ipv6/exthdrs_common.c +238 -0
244 lines not on this page · raw message
net/ipv6/exthdrs_options.c +79 -2
98 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 net-next 6/7] ip6tlvs: Add netlink interface
Quoted 7 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Add a netlink interface to manage the TX TLV parameters. Managed parameters include those for validating and sending TLVs being sent such as alignment, TLV ordering, length limits, etc.
Signed-off-by Tom Herbert <[email protected]>
Hi Tom,
I am wondering if you considered including extack support in this code.
...
Quoted 6 lines
include/uapi/linux/ipeh.h +0
-0@@ -21,4 +21,33 @@ enum {IPEH_TLV_PERM_MAX =IPEH_TLV_PERM_NO_CHECK
include/uapi/linux/ipeh.h enum { · line 31
Quoted 10 lines
include/uapi/linux/ipeh.h +8
-0}; +/* NETLINK_GENERIC related info for IP TLVs */ + +enum { +IPEH_TLV_ATTR_UNSPEC , +IPEH_TLV_ATTR_TYPE ,/* u8, > 1 */ +IPEH_TLV_ATTR_ORDER ,/* u16 */ +IPEH_TLV_ATTR_ADMIN_PERM ,/* u8, perm value */ +IPEH_TLV_ATTR_USER_PERM ,/* u8, perm value */
My reading of struct tlv_tx_params is that admin_perm and user_perm are 2-bit entities whose valid values are currently 0, 1 and 2. Perhaps that would be worth noting here in keeping with restrictions noted for other attributes.
Quoted 12 lines
include/uapi/linux/ipeh.h +12
-0+IPEH_TLV_ATTR_CLASS ,/* u8, 3 bit flags */ +IPEH_TLV_ATTR_ALIGN_MULT ,/* u8, 1 to 16 */ +IPEH_TLV_ATTR_ALIGN_OFF ,/* u8, 0 to 15 */ +IPEH_TLV_ATTR_MIN_DATA_LEN ,/* u8 (option data length) */ +IPEH_TLV_ATTR_MAX_DATA_LEN ,/* u8 (option data length) */ +IPEH_TLV_ATTR_DATA_LEN_MULT ,/* u8, 1 to 16 */ +IPEH_TLV_ATTR_DATA_LEN_OFF ,/* u8, 0 to 15 */ + + __IPEH_TLV_ATTR_MAX, +}; + +#define IPEH_TLV_ATTR_MAX (__IPEH_TLV_ATTR_MAX - 1)
...
Quoted 5 lines
net/ipv6/exthdrs_common.c +0
-0@@ -454,6 +454,244 @@ int __ipeh_tlv_unset(struct tlv_param_table *tlv_param_table,
...
Quoted 67 lines
net/ipv6/exthdrs_common.c +67
-0+int ipeh_tlv_nl_cmd_set (struct tlv_param_table *tlv_param_table, +struct genl_family *tlv_nl_family, +struct sk_buff *skb,struct genl_info *info) +{ +struct tlv_params new_params; +struct tlv_proc *tproc; +unsigned char type; +unsigned int v; +int retv = -EINVAL ; + +if (!info->attrs[IPEH_TLV_ATTR_TYPE ]) +return -EINVAL ; + + type =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_TYPE ]); +if (type <2 ) +return -EINVAL ; + +rcu_read_lock (); + +/* Base new parameters on existing ones */ + tproc =ipeh_tlv_get_proc_by_type (tlv_param_table, type); + new_params = tproc->params; + +if (info->attrs[IPEH_TLV_ATTR_ORDER ]) { + v =nla_get_u16 (info->attrs[IPEH_TLV_ATTR_ORDER ]); + new_params.t.preferred_order = v; + } + +if (info->attrs[IPEH_TLV_ATTR_ADMIN_PERM ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_ADMIN_PERM ]); +if (v >IPEH_TLV_PERM_MAX ) + goto out; + new_params.t.admin_perm = v; + } + +if (info->attrs[IPEH_TLV_ATTR_USER_PERM ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_USER_PERM ]); +if (v >IPEH_TLV_PERM_MAX ) + goto out; + new_params.t.user_perm = v; + } + +if (info->attrs[IPEH_TLV_ATTR_CLASS ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_CLASS ]); +if (!v || (v & ~IPEH_TLV_CLASS_FLAG_MASK )) + goto out; + new_params.t.class = v; + } + +if (info->attrs[IPEH_TLV_ATTR_ALIGN_MULT ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_ALIGN_MULT ]); +if (v >16 || v <1 ) + goto out; + new_params.t.align_mult = v -1 ; + } + +if (info->attrs[IPEH_TLV_ATTR_ALIGN_OFF ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_ALIGN_OFF ]); +if (v >15 ) + goto out; + new_params.t.align_off = v; + } + +if (info->attrs[IPEH_TLV_ATTR_MAX_DATA_LEN ]) + new_params.t.max_data_len = +nla_get_u8 (info->attrs[IPEH_TLV_ATTR_MAX_DATA_LEN ]); +
net/ipv6/exthdrs_common.c int __ipeh_tlv_unset(struct tlv_param_table *tlv_param_table, · line 548
Quoted 10 lines
net/ipv6/exthdrs_common.c +10
-0+if (info->attrs[IPEH_TLV_ATTR_MIN_DATA_LEN ]) + new_params.t.min_data_len = +nla_get_u8 (info->attrs[IPEH_TLV_ATTR_MIN_DATA_LEN ]); + +if (info->attrs[IPEH_TLV_ATTR_DATA_LEN_MULT ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_DATA_LEN_MULT ]); +if (v >16 || v <1 ) + goto out; + new_params.t.data_len_mult = v -1 ; + }
Is some sanity checking warranted for the min/max data len values. f.e. that min <= max ?
Quoted 15 lines
net/ipv6/exthdrs_common.c +15
-0+ +if (info->attrs[IPEH_TLV_ATTR_DATA_LEN_OFF ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_DATA_LEN_OFF ]); +if (v >15 ) + goto out; + new_params.t.data_len_off = v; + } + + retv =ipeh_tlv_set_params (tlv_param_table, type, &new_params); + +out: +rcu_read_unlock (); +return retv; +} +EXPORT_SYMBOL (ipeh_tlv_nl_cmd_set);
...
Re: [PATCH v5 net-next 6/7] ip6tlvs: Add netlink interface
Quoted 8 lines · Simon Horman
Quoted 6 lines · Tom Herbert
From: Tom Herbert <[email protected]>
Add a netlink interface to manage the TX TLV parameters. Managed parameters include those for validating and sending TLVs being sent such as alignment, TLV ordering, length limits, etc.
Quoted 6 lines
Quoted 1 line
Signed-off-by Tom Herbert <[email protected]>Hi Tom,
I am wondering if you considered including extack support in this code.
Good point, will look into adding it.
Quoted 10 lines
...
Quoted 8 lines
include/uapi/linux/ipeh.h +0
-0@@ -21,4 +21,33 @@ enum { IPEH_TLV_PERM_MAX = IPEH_TLV_PERM_NO_CHECK };
Quoted 14 lines
include/uapi/linux/ipeh.h enum { · line 31
Quoted 8 lines
include/uapi/linux/ipeh.h +8
-0+/* NETLINK_GENERIC related info for IP TLVs */ + +enum { +IPEH_TLV_ATTR_UNSPEC , +IPEH_TLV_ATTR_TYPE ,/* u8, > 1 */ +IPEH_TLV_ATTR_ORDER ,/* u16 */ +IPEH_TLV_ATTR_ADMIN_PERM ,/* u8, perm value */ +IPEH_TLV_ATTR_USER_PERM ,/* u8, perm value */ My reading of struct
tlv_tx_paramsis thatadmin_permanduser_permare 2-bit entities whose valid values are currently 0, 1 and 2. Perhaps that would be worth noting here in keeping with restrictions noted for other attributes.
Okay.
Quoted 95 lines
Quoted 12 lines
include/uapi/linux/ipeh.h +12
-0+IPEH_TLV_ATTR_CLASS ,/* u8, 3 bit flags */ +IPEH_TLV_ATTR_ALIGN_MULT ,/* u8, 1 to 16 */ +IPEH_TLV_ATTR_ALIGN_OFF ,/* u8, 0 to 15 */ +IPEH_TLV_ATTR_MIN_DATA_LEN ,/* u8 (option data length) */ +IPEH_TLV_ATTR_MAX_DATA_LEN ,/* u8 (option data length) */ +IPEH_TLV_ATTR_DATA_LEN_MULT ,/* u8, 1 to 16 */ +IPEH_TLV_ATTR_DATA_LEN_OFF ,/* u8, 0 to 15 */ + + __IPEH_TLV_ATTR_MAX, +}; + +#define IPEH_TLV_ATTR_MAX (__IPEH_TLV_ATTR_MAX - 1)...
Quoted 5 lines
net/ipv6/exthdrs_common.c +0
-0@@ -454,6 +454,244 @@ int __ipeh_tlv_unset(struct tlv_param_table *tlv_param_table,...
Quoted 72 lines
net/ipv6/exthdrs_common.c +72
-0+int ipeh_tlv_nl_cmd_set (struct tlv_param_table *tlv_param_table, +struct genl_family *tlv_nl_family, +struct sk_buff *skb,struct genl_info *info) +{ +struct tlv_params new_params; +struct tlv_proc *tproc; +unsigned char type; +unsigned int v; +int retv = -EINVAL ; + +if (!info->attrs[IPEH_TLV_ATTR_TYPE ]) +return -EINVAL ; + + type =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_TYPE ]); +if (type <2 ) +return -EINVAL ; + +rcu_read_lock (); + +/* Base new parameters on existing ones */ + tproc =ipeh_tlv_get_proc_by_type (tlv_param_table, type); + new_params = tproc->params; + +if (info->attrs[IPEH_TLV_ATTR_ORDER ]) { + v =nla_get_u16 (info->attrs[IPEH_TLV_ATTR_ORDER ]); + new_params.t.preferred_order = v; + } + +if (info->attrs[IPEH_TLV_ATTR_ADMIN_PERM ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_ADMIN_PERM ]); +if (v >IPEH_TLV_PERM_MAX ) + goto out; + new_params.t.admin_perm = v; + } + +if (info->attrs[IPEH_TLV_ATTR_USER_PERM ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_USER_PERM ]); +if (v >IPEH_TLV_PERM_MAX ) + goto out; + new_params.t.user_perm = v; + } + +if (info->attrs[IPEH_TLV_ATTR_CLASS ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_CLASS ]); +if (!v || (v & ~IPEH_TLV_CLASS_FLAG_MASK )) + goto out; + new_params.t.class = v; + } + +if (info->attrs[IPEH_TLV_ATTR_ALIGN_MULT ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_ALIGN_MULT ]); +if (v >16 || v <1 ) + goto out; + new_params.t.align_mult = v -1 ; + } + +if (info->attrs[IPEH_TLV_ATTR_ALIGN_OFF ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_ALIGN_OFF ]); +if (v >15 ) + goto out; + new_params.t.align_off = v; + } + +if (info->attrs[IPEH_TLV_ATTR_MAX_DATA_LEN ]) + new_params.t.max_data_len = +nla_get_u8 (info->attrs[IPEH_TLV_ATTR_MAX_DATA_LEN ]); + +if (info->attrs[IPEH_TLV_ATTR_MIN_DATA_LEN ]) + new_params.t.min_data_len = +nla_get_u8 (info->attrs[IPEH_TLV_ATTR_MIN_DATA_LEN ]); + +if (info->attrs[IPEH_TLV_ATTR_DATA_LEN_MULT ]) {
Quoted 8 lines
net/ipv6/exthdrs_common.c int __ipeh_tlv_unset(struct tlv_param_table *tlv_param_table, · line 548
Quoted 5 lines
net/ipv6/exthdrs_common.c +5
-0+ v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_DATA_LEN_MULT ]); +if (v >16 || v <1 ) + goto out; + new_params.t.data_len_mult = v -1 ; + }Is some sanity checking warranted for the min/max data len values. f.e. that min <= max ?
Okay, will add.
Quoted 18 lines
Quoted 16 lines
net/ipv6/exthdrs_common.c +15
-0+ +if (info->attrs[IPEH_TLV_ATTR_DATA_LEN_OFF ]) { + v =nla_get_u8 (info->attrs[IPEH_TLV_ATTR_DATA_LEN_OFF ]); +if (v >15 ) + goto out; + new_params.t.data_len_off = v; + } + + retv =ipeh_tlv_set_params (tlv_param_table, type, &new_params); + +out: +rcu_read_unlock (); +return retv; +} +EXPORT_SYMBOL (ipeh_tlv_nl_cmd_set);...
PATCH v5 7/7 ip6tlvs: Validation of TX Destination and Hop-by-Hop options
In reply to Tom HerbertFrom: Tom Herbert <[email protected]>
Validate Destination and Hop-by-Hop options. This uses the information in the TLV parameters table to validate various aspects of both individual TLVs as well as a list of TLVs in an extension header.
There are two levels of validation that can be performed: simple checks and deep checks. Simple checks validate only the most basic properties such as that the TLV list fits into the EH. Deep checks do a fine grained validation that includes perferred ordering, length limits, and length alignment.
With proper permissions set in the TLV parameter table, this patch allows non-privileged users to send TLVs. Given that TLVs are open ended and potentially a source of DOS attack, deep checks are performed to limit the format that a non-privileged user can send. If deep checks are enabled, a canonical format for sending TLVs is enforced (in adherence with the robustness principle). A TLV must be well ordered with respect to the preferred order for the TLV. Each TLV must be aligned as described in the parameter table. Minimal padding (one padding TLV) is used to align TLVs. The length of the extension header as well as the count of non-padding TLVs is checked against max_*_opts_len and max_*_opts_cnt. For individual TLVs, length limits and length alignment is checked.
--- include/net/ipeh.h | 22 +++ net/ipv6/datagram.c | 51 +++++-- net/ipv6/exthdrs_common.c | 382 ++++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/ipv6_sockglue.c | 39 ++--- 4 files changed, 455 insertions(+), 39 deletions(-)
include/net/ipeh.h +22 -0
@@ -157,6 +157,28 @@ struct ipv6_txoptions *ipeh_renew_options(struct sock *sk,struct ipv6_txoptions *ipeh_fixup_options (struct ipv6_txoptions *opt_space,struct ipv6_txoptions *opt); +int ipeh_opt_validate_tlvs (struct net *net, +struct tlv_param_table *tlv_param_table, +struct ipv6_opt_hdr *opt, +unsigned int optname,bool admin, +unsigned int max_len,unsigned int max_cnt); +int ipeh_opt_validate_single_tlv (struct net *net, +struct tlv_param_table *tlv_param_table, +unsigned int optname,const __u8 *tlv, +size_t len,bool deleting,bool admin); +int ipeh_opt_check_perm (struct net *net, +struct tlv_param_table *tlv_param_table, +struct ipv6_txoptions *txopt,int optname,bool admin); + +struct ipv6_txoptions *ipeh_txopt_from_opt (struct sock *sk, +struct tlv_param_table + *tlv_param_table, +struct ipv6_txoptions *opt, +int optname,char __user *optval, +unsigned int optlen, +unsigned int max_len, +unsigned int max_cnt); +/* Generic extension header TLV parser */ enum ipeh_parse_errors {
net/ipv6/datagram.c +38 -13
96 lines not on this page · raw message
net/ipv6/exthdrs_common.c +382 -0
394 lines not on this page · raw message
net/ipv6/ipv6_sockglue.c +13 -26
@@ -395,40 +395,27 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,case IPV6_RTHDR :case IPV6_DSTOPTS : { +unsigned int max_len =-1U , max_cnt =-1U ;struct ipv6_txoptions *opt; -struct ipv6_opt_hdr *new =NULL ; -/* hop-by-hop / destination options are privileged option */ - retv = -EPERM ; -if (optname !=IPV6_RTHDR && !ns_capable (net->user_ns,CAP_NET_RAW )) +switch (optname) { +case IPV6_HOPOPTS : + max_len = net->ipv6.sysctl.max_hbh_opts_len; + max_cnt = net->ipv6.sysctl.max_hbh_opts_cnt;break ; - -/* remove any sticky options header with a zero option -* length, per RFC3542. -*/ -if (optlen ==0 ) - optval =NULL ; -else if (!optval) - goto e_inval; -else if (optlen <sizeof (struct ipv6_opt_hdr ) || - optlen &0x7 || optlen >8 *255 ) - goto e_inval; -else { - new =memdup_user (optval, optlen); -if (IS_ERR (new)) { - retv =PTR_ERR (new); +case IPV6_RTHDRDSTOPTS : +case IPV6_DSTOPTS : + max_len = net->ipv6.sysctl.max_dst_opts_len; + max_cnt = net->ipv6.sysctl.max_dst_opts_cnt;break ; - } -if (unlikely (ipv6_optlen (new) > optlen)) { -kfree (new); - goto e_inval; - } } opt =rcu_dereference_protected (np->opt,lockdep_sock_is_held (sk)); - opt =ipeh_renew_options (sk, opt, optname, new); -kfree (new); + opt =ipeh_txopt_from_opt (sk, &ipv6_tlv_param_table, opt, + optname, optval, optlen, max_len, + max_cnt); +if (IS_ERR (opt)) { retv =PTR_ERR (opt);break ;
Signature · 1 line
2.7.4