iproute2: sch_rr support in tc
Subsystems (3)
PATCH 1/1 iproute2: sch_rr support in tc
Stephen,
These patches are resubmissions of patches that were approved, but didn't get merged. The first patch is Patrick McHardy's nested compat attribute patch to the netlink libraries. The second patch adds multiqueue and sch_rr functionality to tc. The multiqueue features have been merged to 2.6.23, so we'll need these patches to manage the new kernel features.
These patches are unmodified from the version that was approved. They've been applied to the latest iproute2 commit.
Signature · 1 line
PJ Waskiewicz <[email protected]>
PATCH 1/2 IPROUTE2: RTNETLINK nested attributes
From: Patrick McHardy <[email protected]>
This adds capability for iproute2 to send nested attributes to the kernel, while maintaining backwards compatibility.
---
include/libnetlink.h | 9 +++++++++ lib/libnetlink.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 0 deletions(-)
include/libnetlink.h +9 -0
@@ -39,15 +39,24 @@ extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);extern int addattr32 (struct nlmsghdr *n,int maxlen,int type,__u32 data);extern int addattr_l (struct nlmsghdr *n,int maxlen,int type,const void *data,int alen);extern int addraw_l (struct nlmsghdr *n,int maxlen,const void *data,int len); +extern struct rtattr *addattr_nest (struct nlmsghdr *n,int maxlen,int type); +extern int addattr_nest_end (struct nlmsghdr *n,struct rtattr *nest); +extern struct rtattr *addattr_nest_compat (struct nlmsghdr *n,int maxlen,int type,const void *data,int len); +extern int addattr_nest_compat_end (struct nlmsghdr *n,struct rtattr *nest);extern int rta_addattr32 (struct rtattr *rta,int maxlen,int type,__u32 data);extern int rta_addattr_l (struct rtattr *rta,int maxlen,int type,const void *data,int alen);extern int parse_rtattr (struct rtattr *tb[],int max,struct rtattr *rta,int len);extern int parse_rtattr_byindex (struct rtattr *tb[],int max,struct rtattr *rta,int len); +extern int __parse_rtattr_nested_compat (struct rtattr *tb[],int max,struct rtattr *rta,int len);#define parse_rtattr_nested (tb, max, rta) \ (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))) +#define parse_rtattr_nested_compat (tb, max, rta, data, len) \ +({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \ + __parse_rtattr_nested_compat(tb, max, rta, len); }) +extern int rtnl_listen (struct rtnl_handle *,rtnl_filter_t handler,void *jarg); extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
lib/libnetlink.c +46 -0
55 lines not on this page · raw message
PATCH 2/2 iproute2: sch_rr support in tc
In reply to PJ WaskiewiczThis patch applies on top of Patrick McHardy's RTNETLINK patches to add nested compat attributes. This is needed to maintain ABI for sch_{rr|prio} in the kernel with respect to tc. A new option, namely multiqueue, was added to sch_prio and sch_rr. This will allow a user to turn multiqueue support on for sch_prio or sch_rr at loadtime. Also, tc qdisc ls will display whether or not multiqueue is enabled on that qdisc. When in multiqueue mode, a user can specify a value of 0 for bands, and the number of bands will be created to match the number of queues on the device.
This patch is to support the new sch_rr (round-robin) qdisc being proposed in NET for multiqueue network device support in the Linux network stack. It uses q_prio.c as the template, since the qdiscs are nearly identical, outside of the ->dequeue() routine.
---
include/linux/pkt_sched.h | 9 +++ tc/q_prio.c | 24 +++++++-- tc/q_rr.c | 127 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 5 deletions(-)
include/linux/pkt_sched.h +9 -0
@@ -101,6 +101,15 @@ struct tc_prio_qopt__u8 priomap[TC_PRIO_MAX +1 ];/* Map: logical priority -> PRIO band */ }; +enum +{ +TCA_PRIO_UNSPEC , +TCA_PRIO_MQ , + __TCA_PRIO_MAX +}; + +#define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1) +/* TBF section */ struct tc_tbf_qopt
tc/q_prio.c +19 -5
@@ -29,7 +29,7 @@static void explain (void ) { -fprintf (stderr,"Usage: ... prio bands NUMBER priomap P1 P2...\n" ); +fprintf (stderr,"Usage: ... prio bands NUMBER priomap P1 P2...[multiqueue]\n" ); }#define usage () return(-1)
@@ -40,6 +40,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nint pmap_mode =0 ;int idx =0 ;struct tc_prio_qopt opt={3 ,{1 ,2 ,2 ,2 ,1 ,2 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 }}; +struct rtattr *nest; +unsigned char mq =0 ;while (argc >0 ) {if (strcmp (*argv,"bands" ) ==0 ) {
@@ -57,6 +59,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nreturn -1 ; } pmap_mode =1 ; + }else if (strcmp (*argv,"multiqueue" ) ==0 ) { + mq =1 ; }else if (strcmp (*argv,"help" ) ==0 ) {explain ();return -1 ;
@@ -90,7 +94,10 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nopt.priomap[idx] = opt.priomap[TC_PRIO_BESTEFFORT]; } */ -addattr_l (n,1024 ,TCA_OPTIONS , &opt,sizeof (opt)); + nest =addattr_nest_compat (n,1024 ,TCA_OPTIONS , &opt,sizeof (opt)); +if (mq) +addattr_l (n,1024 ,TCA_PRIO_MQ ,NULL ,0 ); +addattr_nest_compat_end (n, nest);return 0 ; }
@@ -98,16 +105,23 @@ int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {int i;struct tc_prio_qopt *qopt; +struct rtattr *tb[TCA_PRIO_MAX +1 ];if (opt ==NULL )return 0 ; -if (RTA_PAYLOAD (opt) <sizeof (*qopt)) -return -1 ; - qopt =RTA_DATA (opt); +if (parse_rtattr_nested_compat (tb,TCA_PRIO_MAX , opt, qopt, +sizeof (*qopt))) +return -1 ; +fprintf (f,"bands %u priomap " , qopt->bands);for (i=0 ; i<=TC_PRIO_MAX ; i++)fprintf (f," %d" , qopt->priomap[i]); + +if (tb[TCA_PRIO_MQ ]) +fprintf (f," multiqueue: %s " , + *(unsigned char *)RTA_DATA (tb[TCA_PRIO_MQ ]) ?"on" :"off" ); +return 0 ; }
tc/q_rr.c new file +127 -0
127 lines not on this page · raw message