From 11f2c753155b1cdcc3dd62769183b462ad85ef43 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Thu, 19 Jan 2017 09:08:21 -0800 Subject: [PATCH 1/4] ip route: error out on multiple via without nexthop keyword To specify multiple nexthops in a route the user is expected to use the "nexthop" keyword which ip route uses to create the RTA_MULTIPATH. However, ip route always accepts multiple 'via' keywords where only the last one is used in the route leading to confusion. For example, ip accepts this syntax: $ ip ro add vrf red 1.1.1.0/24 via 10.100.1.18 via 10.100.2.18 but the route entered inserted by the kernel is just the last gateway: 1.1.1.0/24 via 10.100.2.18 dev eth2 which is not the full request from the user. Detect the presense of multiple 'via' and give the user a hint to add nexthop: $ ip ro add vrf red 1.1.1.0/24 via 10.100.1.18 via 10.100.2.18 Error: argument "via" is wrong: use nexthop syntax to specify multiple via Signed-off-by: David Ahern Signed-off-by: Stephen Hemminger --- ip/iproute.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ip/iproute.c b/ip/iproute.c index e433de8b..52dbdc7d 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -881,6 +881,10 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv) inet_prefix addr; int family; + if (gw_ok) { + invarg("use nexthop syntax to specify multiple via\n", + *argv); + } gw_ok = 1; NEXT_ARG(); family = read_family(*argv); From 4f7d406f5dc89229d8aec8b723015c06db343e17 Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Fri, 20 Jan 2017 14:07:38 -0500 Subject: [PATCH 2/4] f_flower: don't set TCA_FLOWER_KEY_ETH_TYPE for "protocol all" v2 - update to address changes in 00697ca19ae3e1118f2af82c3b41ac4335fe918b. When using the tc flower filter, 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. Fixes: 488b41d020fb ("tc: flower no need to specify the ethertype") Cc: Jamal Hadi Salim Signed-off-by: Benjamin LaHaise Signed-off-by: Benjamin LaHaise Reviewed-by: Roi Dayan --- tc/f_flower.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tc/f_flower.c b/tc/f_flower.c index 314c2dd1..145a8566 100644 --- a/tc/f_flower.c +++ b/tc/f_flower.c @@ -529,9 +529,11 @@ parse_done: if (ret) return ret; - ret = addattr16(n, MAX_MSG, TCA_FLOWER_KEY_ETH_TYPE, eth_type); - if (ret) - return ret; + if (eth_type != htons(ETH_P_ALL)) { + ret = addattr16(n, MAX_MSG, TCA_FLOWER_KEY_ETH_TYPE, eth_type); + if (ret) + return ret; + } tail->rta_len = (((void *)n)+n->nlmsg_len) - (void *)tail; From 6bbe5e6290db5cf3e78d6a1a179c76535a2eea3f Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sat, 28 Jan 2017 12:59:10 +0100 Subject: [PATCH 3/4] man: tc-csum.8: Fix example This fixes two issues with the provided example: - Add missing 'dev' keyword to second command. - Use a real IPv4 address instead of a bogus hex value since that will be rejected by get_addr_ipv4(). Fixes: dbfb17a67f9c7 ("man: tc-csum.8: Add an example") Reported-by: Davide Caratti Signed-off-by: Phil Sutter --- man/man8/tc-csum.8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/man8/tc-csum.8 b/man/man8/tc-csum.8 index 3a64c82f..68e56105 100644 --- a/man/man8/tc-csum.8 +++ b/man/man8/tc-csum.8 @@ -57,9 +57,9 @@ packets, both IP and UDP checksums have to be recalculated: .RS .EX # tc qdisc add dev eth0 ingress handle ffff: -# tc filter add eth0 prio 1 protocol ip parent ffff: \\ - u32 match ip src 192.168.1.100/32 flowid :1 \\ - action pedit munge ip dst set 0x12345678 pipe \\ +# tc filter add dev eth0 prio 1 protocol ip parent ffff: \\ + u32 match ip src 192.0.2.100/32 flowid :1 \\ + action pedit munge ip dst set 198.51.100.1 pipe \\ csum ip and udp .EE .RE From 31951c47e94337d26b79be2360df3c5a956aaa6a Mon Sep 17 00:00:00 2001 From: Roman Mashak Date: Sun, 22 Jan 2017 08:55:33 -0500 Subject: [PATCH 4/4] tc: distinguish Add/Replace action operations. Signed-off-by: Roman Mashak Signed-off-by: Jamal Hadi Salim Acked-by: Phil Sutter --- tc/m_action.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tc/m_action.c b/tc/m_action.c index bb19df88..05ef07e0 100644 --- a/tc/m_action.c +++ b/tc/m_action.c @@ -365,12 +365,18 @@ int print_action(const struct sockaddr_nl *who, fprintf(fp, "Flushed table "); tab_flush = 1; } else { - fprintf(fp, "deleted action "); + fprintf(fp, "Deleted action "); } } - if (n->nlmsg_type == RTM_NEWACTION) - fprintf(fp, "Added action "); + if (n->nlmsg_type == RTM_NEWACTION) { + if ((n->nlmsg_flags & NLM_F_CREATE) && + !(n->nlmsg_flags & NLM_F_REPLACE)) { + fprintf(fp, "Added action "); + } else if (n->nlmsg_flags & NLM_F_REPLACE) { + fprintf(fp, "Replaced action "); + } + } tc_print_action(fp, tb[TCA_ACT_TAB]); return 0;