summaryrefslogtreecommitdiff
path: root/net/openvswitch
diff options
context:
space:
mode:
authorEelco Chaudron <echaudro@redhat.com>2020-12-07 13:08:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-02-23 17:53:23 +0300
commit2bce178c254c5df3df353962b891d2cc63c4afed (patch)
treeaafddb189a9ba765e8cc9f349e62d50395c1f243 /net/openvswitch
parent78b12034d4c394a9d7c9fa47c6b738fb0571b218 (diff)
downloadlinux-2bce178c254c5df3df353962b891d2cc63c4afed.tar.xz
net: openvswitch: fix TTL decrement exception action execution
[ Upstream commit 09d6217254c004f6237cc2c2bfe604af58e9a8c5 ] Currently, the exception actions are not processed correctly as the wrong dataset is passed. This change fixes this, including the misleading comment. In addition, a check was added to make sure we work on an IPv4 packet, and not just assume if it's not IPv6 it's IPv4. This was all tested using OVS with patch, https://patchwork.ozlabs.org/project/openvswitch/list/?series=21639, applied and sending packets with a TTL of 1 (and 0), both with IPv4 and IPv6. Fixes: 69929d4c49e1 ("net: openvswitch: fix TTL decrement action netlink message format") Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Link: https://lore.kernel.org/r/160733569860.3007.12938188180387116741.stgit@wsfd-netdev64.ntdv.lab.eng.bos.redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/openvswitch')
-rw-r--r--net/openvswitch/actions.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index c3a664871cb5..e8902a7e60f2 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -959,16 +959,13 @@ static int dec_ttl_exception_handler(struct datapath *dp, struct sk_buff *skb,
struct sw_flow_key *key,
const struct nlattr *attr, bool last)
{
- /* The first action is always 'OVS_DEC_TTL_ATTR_ARG'. */
- struct nlattr *dec_ttl_arg = nla_data(attr);
+ /* The first attribute is always 'OVS_DEC_TTL_ATTR_ACTION'. */
+ struct nlattr *actions = nla_data(attr);
- if (nla_len(dec_ttl_arg)) {
- struct nlattr *actions = nla_data(dec_ttl_arg);
+ if (nla_len(actions))
+ return clone_execute(dp, skb, key, 0, nla_data(actions),
+ nla_len(actions), last, false);
- if (actions)
- return clone_execute(dp, skb, key, 0, nla_data(actions),
- nla_len(actions), last, false);
- }
consume_skb(skb);
return 0;
}
@@ -1212,7 +1209,7 @@ static int execute_dec_ttl(struct sk_buff *skb, struct sw_flow_key *key)
return -EHOSTUNREACH;
key->ip.ttl = --nh->hop_limit;
- } else {
+ } else if (skb->protocol == htons(ETH_P_IP)) {
struct iphdr *nh;
u8 old_ttl;