diff mbox

[iproute2] f_flower: don't set TCA_FLOWER_KEY_ETH_TYPE for "protocol all"

Message ID 20170119215159.GA32126@nvt-d.home.kvack.org
State Changes Requested, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Benjamin LaHaise Jan. 19, 2017, 9:51 p.m. UTC
When using the tc filter flower, rules marked with "protocol all" do not
actually match all packets.  This is due to a bug in f_flower.c that passes
in ETH_P_ALL in the TCA_FLOWER_KEY_ETH_TYPE attribute when adding a rule.
Fix this by omitting TCA_FLOWER_KEY_ETH_TYPE if the protocol is set to
ETH_P_ALL.
    
Signed-off-by: Benjamin LaHaise <benjamin.lahaise@netronome.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>

Comments

Stephen Hemminger Jan. 20, 2017, 5:34 p.m. UTC | #1
On Thu, 19 Jan 2017 16:51:59 -0500
Benjamin LaHaise <benjamin.lahaise@netronome.com> wrote:

> When using the tc filter flower, rules marked with "protocol all" do not
> actually match all packets.  This is due to a bug in f_flower.c that passes
> in ETH_P_ALL in the TCA_FLOWER_KEY_ETH_TYPE attribute when adding a rule.
> Fix this by omitting TCA_FLOWER_KEY_ETH_TYPE if the protocol is set to
> ETH_P_ALL.
>     
> Signed-off-by: Benjamin LaHaise <benjamin.lahaise@netronome.com>
> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>

This looks good, but does not apply cleanly to either master or net-next branch
of current repository. Please rebase and resubmit.

It would be helpful to to use Fixes: tag for something which was broken by
a single previous commit.
diff mbox

Patch

diff --git a/tc/f_flower.c b/tc/f_flower.c
index 1dbc532..1f90da3 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -527,11 +527,13 @@  static int flower_parse_opt(struct filter_util *qu, char *handle,
 parse_done:
 	addattr32(n, MAX_MSG, TCA_FLOWER_FLAGS, flags);
 
-	ret = addattr16(n, MAX_MSG, TCA_FLOWER_KEY_ETH_TYPE, eth_type);
-	if (ret) {
-		fprintf(stderr, "Illegal \"eth_type\"(0x%x)\n",
-			ntohs(eth_type));
-		return -1;
+	if (eth_type != htons(ETH_P_ALL)) {
+		ret = addattr16(n, MAX_MSG, TCA_FLOWER_KEY_ETH_TYPE, eth_type);
+		if (ret) {
+			fprintf(stderr, "Illegal \"eth_type\"(0x%x)\n",
+				ntohs(eth_type));
+			return -1;
+		}
 	}
 
 	tail->rta_len = (((void *)n)+n->nlmsg_len) - (void *)tail;