Re: [PATCH net-next v3 1/1] net sched actions: Add support for user cookies
From: Jamal Hadi Salim Date: Tue, 17 Jan 2017 05:52:15 -0500 > Having said that: Is this rule really cast in stone?;-> > I have seen many other people (including myself) sneak in whitespace > changes and other trivialities in a general change. I thought the rule > was to not do such things for bug fixes. Sneaking patches that do things they shouldn't past me doesn't make it the new rule.
Re: [PATCH net-next v3 1/1] net sched actions: Add support for user cookies
On 17-01-16 02:46 PM, David Miller wrote: Jamal, please don't mix coding style and real changes. Have one patch that adds the user cookies and one that cleans up the coding style stuff. Thanks. I will separate those changes (gives me an opportunity to make more stylistic changes). Having said that: Is this rule really cast in stone?;-> I have seen many other people (including myself) sneak in whitespace changes and other trivialities in a general change. I thought the rule was to not do such things for bug fixes. cheers, jamal
Re: [PATCH net-next v3 1/1] net sched actions: Add support for user cookies
Jamal, please don't mix coding style and real changes. Have one patch that adds the user cookies and one that cleans up the coding style stuff. Thanks.
Re: [PATCH net-next v3 1/1] net sched actions: Add support for user cookies
Sun, Jan 15, 2017 at 04:18:20PM CET, j...@mojatatu.com wrote: >On 17-01-15 10:01 AM, Jiri Pirko wrote: >> Sun, Jan 15, 2017 at 03:01:19PM CET, j...@mojatatu.com wrote: > >> > +cls_set_class(struct tcf_proto *tp, unsigned long *clp, >> >> ?? >> >> >unsigned long cl) >> > { >> >unsigned long old_cl; >> > - >> > + >> >> ?? >> >> >tcf_tree_lock(tp); >> >old_cl = __cls_set_class(clp, cl); >> >tcf_tree_unlock(tp); >> > - >> > + >> >> ?? >> >> >return old_cl; >> > } >> > >> > @@ -237,7 +237,7 @@ static inline int tcf_em_early_end(struct tcf_ematch >> > *em, int result) >> > >> >return 0; >> > } >> > - >> > + >> >> ?? >> > >All these things with "??" were annoying whitespace and stylistic >things my fingers couldnt resist. It is legit to include such changes >in a patch when touching the code (as long as not a bug fix). Well, I think you should change this in a separate patch as it has 0 relation with this patch.
Re: [PATCH net-next v3 1/1] net sched actions: Add support for user cookies
On 17-01-15 10:01 AM, Jiri Pirko wrote: Sun, Jan 15, 2017 at 03:01:19PM CET, j...@mojatatu.com wrote: +cls_set_class(struct tcf_proto *tp, unsigned long *clp, ?? unsigned long cl) { unsigned long old_cl; - + ?? tcf_tree_lock(tp); old_cl = __cls_set_class(clp, cl); tcf_tree_unlock(tp); - + ?? return old_cl; } @@ -237,7 +237,7 @@ static inline int tcf_em_early_end(struct tcf_ematch *em, int result) return 0; } - + ?? All these things with "??" were annoying whitespace and stylistic things my fingers couldnt resist. It is legit to include such changes in a patch when touching the code (as long as not a bug fix). cheers, jamal
Re: [PATCH net-next v3 1/1] net sched actions: Add support for user cookies
Sun, Jan 15, 2017 at 03:01:19PM CET, j...@mojatatu.com wrote: >From: Jamal Hadi Salim > >Introduce optional 128-bit action cookie. >Like all other cookie schemes in the networking world (eg in protocols >like http or existing kernel fib protocol field, etc) the idea is to save >user state that when retrieved serves as a correlator. The kernel >_should not_ intepret it. The user can store whatever they wish in the >128 bits. > >Sample exercise(showing variable length use of cookie) > >.. create an accept action with cookie a1b2c3d4 >sudo $TC actions add action ok index 1 cookie a1b2c3d4 > >.. dump all gact actions.. >sudo $TC -s actions ls action gact > > action order 0: gact action pass >random type none pass val 0 >index 1 ref 1 bind 0 installed 5 sec used 5 sec > Action statistics: > Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) > backlog 0b 0p requeues 0 > cookie a1b2c3d4 > >.. bind the accept action to a filter.. >sudo $TC filter add dev lo parent : protocol ip prio 1 \ >u32 match ip dst 127.0.0.1/32 flowid 1:1 action gact index 1 > >... send some traffic.. >$ ping 127.0.0.1 -c 3 >PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. >64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.020 ms >64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms >64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.038 ms > >--- 127.0.0.1 ping statistics --- >3 packets transmitted, 3 received, 0% packet loss, time 2109ms >rtt min/avg/max/mdev = 0.020/0.028/0.038/0.008 ms 1 > >... show some stats >$ sudo $TC -s actions get action gact index 1 > > action order 1: gact action pass >random type none pass val 0 >index 1 ref 2 bind 1 installed 204 sec used 5 sec > Action statistics: >Sent 12168 bytes 164 pkt (dropped 0, overlimits 0 requeues 0) > backlog 0b 0p requeues 0 > cookie a1b2c3d4 > >.. try longer cookie... >$ sudo $TC actions replace action ok index 1 cookie 1234567890abcdef >.. dump.. >$ sudo $TC -s actions ls action gact > > action order 1: gact action pass >random type none pass val 0 >index 1 ref 2 bind 1 installed 204 sec used 5 sec > Action statistics: >Sent 12168 bytes 164 pkt (dropped 0, overlimits 0 requeues 0) > backlog 0b 0p requeues 0 > cookie 1234567890abcdef > >Signed-off-by: Jamal Hadi Salim >--- > include/net/act_api.h| 1 + > include/net/pkt_cls.h| 19 +-- > include/uapi/linux/pkt_cls.h | 3 +++ > net/sched/act_api.c | 29 +++-- > 4 files changed, 44 insertions(+), 8 deletions(-) > >diff --git a/include/net/act_api.h b/include/net/act_api.h >index 1d71644..0692458 100644 >--- a/include/net/act_api.h >+++ b/include/net/act_api.h >@@ -41,6 +41,7 @@ struct tc_action { > struct rcu_head tcfa_rcu; > struct gnet_stats_basic_cpu __percpu *cpu_bstats; > struct gnet_stats_queue __percpu *cpu_qstats; >+ struct tc_cookie*act_ck; > }; > #define tcf_head common.tcfa_head > #define tcf_index common.tcfa_index >diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h >index f0a0514..f2fafeb 100644 >--- a/include/net/pkt_cls.h >+++ b/include/net/pkt_cls.h >@@ -24,15 +24,15 @@ struct tcf_walker { > } > > static inline unsigned long >-cls_set_class(struct tcf_proto *tp, unsigned long *clp, >+cls_set_class(struct tcf_proto *tp, unsigned long *clp, ?? > unsigned long cl) > { > unsigned long old_cl; >- >+ ?? > tcf_tree_lock(tp); > old_cl = __cls_set_class(clp, cl); > tcf_tree_unlock(tp); >- >+ ?? > return old_cl; > } > >@@ -237,7 +237,7 @@ static inline int tcf_em_early_end(struct tcf_ematch *em, >int result) > > return 0; > } >- >+ ?? > /** > * struct tcf_ematch_tree - ematch tree handle > * >@@ -246,8 +246,7 @@ static inline int tcf_em_early_end(struct tcf_ematch *em, >int result) > */ > struct tcf_ematch_tree { > struct tcf_ematch_tree_hdr hdr; >- struct tcf_ematch * matches; >- >+ struct tcf_ematch *matches; ?? > }; > > /** >@@ -515,4 +514,12 @@ struct tc_cls_bpf_offload { > u32 gen_flags; > }; > >+ >+/* This structure holds cookie structure that is passed from user >+ * to the kernel for actions and classifiers You can add "." to the end of the sentence in V4. >+ */ >+struct tc_cookie { >+ unsigned char ck[TC_COOKIE_MAX_SIZE]; >+ unsigned char ck_len; >+}; > #endif >diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h >index 1e5e1dd..2d2414e 100644 >--- a/include/uapi/linux/pkt_cls.h >+++ b/include/uapi/linux/pkt_cls.h >@@ -4,6 +4,8 @@ > #include > #include > >+#define TC_COOKIE_MAX_SIZE 16 >+ > /* Action attributes */ > enum { > TCA_ACT_UNSPEC, >@@ -12,6 +14,7 @@ enum { > TCA_ACT_INDEX, > TCA_ACT_STATS, > TCA_ACT_PAD, >+ TCA_ACT_COOKIE, > __TCA_ACT_MAX > }; > >diff --
[PATCH net-next v3 1/1] net sched actions: Add support for user cookies
From: Jamal Hadi Salim Introduce optional 128-bit action cookie. Like all other cookie schemes in the networking world (eg in protocols like http or existing kernel fib protocol field, etc) the idea is to save user state that when retrieved serves as a correlator. The kernel _should not_ intepret it. The user can store whatever they wish in the 128 bits. Sample exercise(showing variable length use of cookie) .. create an accept action with cookie a1b2c3d4 sudo $TC actions add action ok index 1 cookie a1b2c3d4 .. dump all gact actions.. sudo $TC -s actions ls action gact action order 0: gact action pass random type none pass val 0 index 1 ref 1 bind 0 installed 5 sec used 5 sec Action statistics: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 cookie a1b2c3d4 .. bind the accept action to a filter.. sudo $TC filter add dev lo parent : protocol ip prio 1 \ u32 match ip dst 127.0.0.1/32 flowid 1:1 action gact index 1 ... send some traffic.. $ ping 127.0.0.1 -c 3 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.020 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.038 ms --- 127.0.0.1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2109ms rtt min/avg/max/mdev = 0.020/0.028/0.038/0.008 ms 1 ... show some stats $ sudo $TC -s actions get action gact index 1 action order 1: gact action pass random type none pass val 0 index 1 ref 2 bind 1 installed 204 sec used 5 sec Action statistics: Sent 12168 bytes 164 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 cookie a1b2c3d4 .. try longer cookie... $ sudo $TC actions replace action ok index 1 cookie 1234567890abcdef .. dump.. $ sudo $TC -s actions ls action gact action order 1: gact action pass random type none pass val 0 index 1 ref 2 bind 1 installed 204 sec used 5 sec Action statistics: Sent 12168 bytes 164 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 cookie 1234567890abcdef Signed-off-by: Jamal Hadi Salim --- include/net/act_api.h| 1 + include/net/pkt_cls.h| 19 +-- include/uapi/linux/pkt_cls.h | 3 +++ net/sched/act_api.c | 29 +++-- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 1d71644..0692458 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -41,6 +41,7 @@ struct tc_action { struct rcu_head tcfa_rcu; struct gnet_stats_basic_cpu __percpu *cpu_bstats; struct gnet_stats_queue __percpu *cpu_qstats; + struct tc_cookie*act_ck; }; #define tcf_head common.tcfa_head #define tcf_index common.tcfa_index diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index f0a0514..f2fafeb 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -24,15 +24,15 @@ struct tcf_walker { } static inline unsigned long -cls_set_class(struct tcf_proto *tp, unsigned long *clp, +cls_set_class(struct tcf_proto *tp, unsigned long *clp, unsigned long cl) { unsigned long old_cl; - + tcf_tree_lock(tp); old_cl = __cls_set_class(clp, cl); tcf_tree_unlock(tp); - + return old_cl; } @@ -237,7 +237,7 @@ static inline int tcf_em_early_end(struct tcf_ematch *em, int result) return 0; } - + /** * struct tcf_ematch_tree - ematch tree handle * @@ -246,8 +246,7 @@ static inline int tcf_em_early_end(struct tcf_ematch *em, int result) */ struct tcf_ematch_tree { struct tcf_ematch_tree_hdr hdr; - struct tcf_ematch * matches; - + struct tcf_ematch *matches; }; /** @@ -515,4 +514,12 @@ struct tc_cls_bpf_offload { u32 gen_flags; }; + +/* This structure holds cookie structure that is passed from user + * to the kernel for actions and classifiers + */ +struct tc_cookie { + unsigned char ck[TC_COOKIE_MAX_SIZE]; + unsigned char ck_len; +}; #endif diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 1e5e1dd..2d2414e 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -4,6 +4,8 @@ #include #include +#define TC_COOKIE_MAX_SIZE 16 + /* Action attributes */ enum { TCA_ACT_UNSPEC, @@ -12,6 +14,7 @@ enum { TCA_ACT_INDEX, TCA_ACT_STATS, TCA_ACT_PAD, + TCA_ACT_COOKIE, __TCA_ACT_MAX }; diff --git a/net/sched/act_api.c b/net/sched/act_api.c index f04715a..9d05b70 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ static void free_tcf(st