All of lore.kernel.org
 help / color / mirror / Atom feed
* fw mark based tc class selection not working
@ 2015-09-11  5:31 Akshat Kakkar
  2015-09-11 10:52 ` Andy Furniss
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Akshat Kakkar @ 2015-09-11  5:31 UTC (permalink / raw)
  To: lartc

Recently I came to know that,
Without any options fw classifier maps fwmark to classid.

tc filter add dev <iface> parent <qhandle> protocol ip prio 1 fw

i.e. if my packet has mark(0x10001) and class id is not set,
then above tc filter, will set class id = 0x10001 i.e. 1:1

But when I am trying it out, its not working!
I am having class 1:1 defined but its not at all hit.

Am I missing something out here?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fw mark based tc class selection not working
  2015-09-11  5:31 fw mark based tc class selection not working Akshat Kakkar
@ 2015-09-11 10:52 ` Andy Furniss
  2015-09-11 11:54 ` Akshat Kakkar
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Furniss @ 2015-09-11 10:52 UTC (permalink / raw)
  To: lartc

Akshat Kakkar wrote:
> Recently I came to know that, Without any options fw classifier maps
> fwmark to classid.
>
> tc filter add dev <iface> parent <qhandle> protocol ip prio 1 fw
>
> i.e. if my packet has mark(0x10001) and class id is not set, then
> above tc filter, will set class id = 0x10001 i.e. 1:1
>
> But when I am trying it out, its not working! I am having class 1:1
> defined but its not at all hit.
>
> Am I missing something out here?

Seems to be broken, below is a paste from a mail I sent to this list 2
years ago showing it working. The same test now (apart from I am using
eth2 instead of eth0) doesn't work.

tc qdisc add dev eth0 root handle 1: htb
tc class add dev eth0 parent 1: classid 1:a htb rate 1mbit
tc class add dev eth0 parent 1: classid 1:b htb rate 1mbit
tc class add dev eth0 parent 1: classid 1:c htb rate 1mbit
tc filter add dev eth0 parent 1:0 protocol ip fw

iptables -t mangle -I OUTPUT -o eth0 -p tcp -j MARK --set-mark 0x1000a
iptables -t mangle -I OUTPUT -o eth0 -p icmp -j MARK --set-mark 0x1000b
iptables -t mangle -I OUTPUT -o eth0 -p udp -j MARK --set-mark 0x1000c


ph4[/home/andy]# iptables -L OUTPUT -vnt mangle

Chain OUTPUT (policy ACCEPT 84 packets, 14747 bytes)
pkts bytes target     prot opt in     out     source destination
    3   196 MARK       udp  --  *      eth0    0.0.0.0/0 0.0.0.0/0 
       MARK set 0x1000c
    7   588 MARK       icmp --  *      eth0    0.0.0.0/0 0.0.0.0/0 
       MARK set 0x1000b
   74 13963 MARK       tcp  --  *      eth0    0.0.0.0/0 0.0.0.0/0 
       MARK set 0x1000a


ph4[/home/andy]# tc -s class ls dev eth0

class htb 1:c root prio 0 rate 1000Kbit ceil 1000Kbit burst 2850b cburst 
2850b
Sent 238 bytes 3 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 3 borrowed: 0 giants: 0
tokens: 346750 ctokens: 346750

class htb 1:a root prio 0 rate 1000Kbit ceil 1000Kbit burst 2850b cburst 
2850b
Sent 14999 bytes 74 pkt (dropped 0, overlimits 0 requeues 0)
rate 32bit 0pps backlog 0b 0p requeues 0
lended: 74 borrowed: 0 giants: 0
tokens: 348000 ctokens: 348000

class htb 1:b root prio 0 rate 1000Kbit ceil 1000Kbit burst 2850b cburst 
2850b
Sent 686 bytes 7 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 7 borrowed: 0 giants: 0
tokens: 344000 ctokens: 344000


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fw mark based tc class selection not working
  2015-09-11  5:31 fw mark based tc class selection not working Akshat Kakkar
  2015-09-11 10:52 ` Andy Furniss
@ 2015-09-11 11:54 ` Akshat Kakkar
  2015-09-12  9:25 ` Andy Furniss
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Akshat Kakkar @ 2015-09-11 11:54 UTC (permalink / raw)
  To: lartc

> Seems to be broken, below is a paste from a mail I sent to this list 2
> years ago showing it working. The same test now (apart from I am using
> eth2 instead of eth0) doesn't work.

Should we file a bug for this on netdev?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fw mark based tc class selection not working
  2015-09-11  5:31 fw mark based tc class selection not working Akshat Kakkar
  2015-09-11 10:52 ` Andy Furniss
  2015-09-11 11:54 ` Akshat Kakkar
@ 2015-09-12  9:25 ` Andy Furniss
  2015-09-12 11:29 ` Andy Furniss
  2015-09-12 17:52 ` Akshat Kakkar
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Furniss @ 2015-09-12  9:25 UTC (permalink / raw)
  To: lartc

Akshat Kakkar wrote:
>> Seems to be broken, below is a paste from a mail I sent to this
>> list 2 years ago showing it working. The same test now (apart from
>>  I am using eth2 instead of eth0) doesn't work.
>
> Should we file a bug for this on netdev?

I guess so.

I tried some older versions of iproute2 on current kernel, but no luck
there.

Since getting a new GPU which needs latest I deleted all of my old
kernels and would have to mess around a bit to run them now.

I am not on netdev, but if it is a bug finding when it regressed will
be helpful for them.

Failing that post it anyway - it may be deliberate and there is some
other way to do the same thing now.

iptables/netfilter is also something to consider, though my failed test
still works if I match marks with u32, so they are getting set OK.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fw mark based tc class selection not working
  2015-09-11  5:31 fw mark based tc class selection not working Akshat Kakkar
                   ` (2 preceding siblings ...)
  2015-09-12  9:25 ` Andy Furniss
@ 2015-09-12 11:29 ` Andy Furniss
  2015-09-12 17:52 ` Akshat Kakkar
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Furniss @ 2015-09-12 11:29 UTC (permalink / raw)
  To: lartc

Akshat Kakkar wrote:
> I hv got a reply from Cong Wang on netdev, saying it might be broken
> coz of his tc-init function and has provided a patch for it.  I have
> attached that patch over here.

Attachment didn't make it, but I got the patch from netdev archive and
it works for me.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fw mark based tc class selection not working
  2015-09-11  5:31 fw mark based tc class selection not working Akshat Kakkar
                   ` (3 preceding siblings ...)
  2015-09-12 11:29 ` Andy Furniss
@ 2015-09-12 17:52 ` Akshat Kakkar
  4 siblings, 0 replies; 6+ messages in thread
From: Akshat Kakkar @ 2015-09-12 17:52 UTC (permalink / raw)
  To: lartc

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]

I have attached the patch herewith.

[-- Attachment #2: cls_fw.diff --]
[-- Type: text/plain, Size: 971 bytes --]

diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index 715e01e..b6394ab 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -34,6 +34,7 @@
 struct fw_head {
 	u32			mask;
 	bool			mask_set;
+	bool			old_method;
 	struct fw_filter __rcu	*ht[HTSIZE];
 	struct rcu_head		rcu;
 };
@@ -65,7 +66,7 @@ static int fw_classify(struct sk_buff *skb, const struct tcf_proto *tp,
 	int r;
 	u32 id = skb->mark;
 
-	if (head != NULL) {
+	if (!head->old_method) {
 		id &= head->mask;
 
 		for (f = rcu_dereference_bh(head->ht[fw_hash(id)]); f;
@@ -120,6 +121,7 @@ static int fw_init(struct tcf_proto *tp)
 	if (head == NULL)
 		return -ENOBUFS;
 
+	head->old_method = true;
 	head->mask_set = false;
 	rcu_assign_pointer(tp->root, head);
 	return 0;
@@ -302,6 +304,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
 	if (!handle)
 		return -EINVAL;
 
+	head->old_method = false;
 	if (!head->mask_set) {
 		head->mask = 0xFFFFFFFF;
 		if (tb[TCA_FW_MASK])

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-12 17:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-11  5:31 fw mark based tc class selection not working Akshat Kakkar
2015-09-11 10:52 ` Andy Furniss
2015-09-11 11:54 ` Akshat Kakkar
2015-09-12  9:25 ` Andy Furniss
2015-09-12 11:29 ` Andy Furniss
2015-09-12 17:52 ` Akshat Kakkar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.