Skip to content

Commit 2bce178

Browse files
chaudrongregkh
authored andcommitted
net: openvswitch: fix TTL decrement exception action execution
[ Upstream commit 09d6217 ] 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: 69929d4 ("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>
1 parent 78b1203 commit 2bce178

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

‎net/openvswitch/actions.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -959,16 +959,13 @@ static int dec_ttl_exception_handler(struct datapath *dp, struct sk_buff *skb,
959959
struct sw_flow_key *key,
960960
const struct nlattr *attr, bool last)
961961
{
962-
/* The first action is always 'OVS_DEC_TTL_ATTR_ARG'. */
963-
struct nlattr *dec_ttl_arg = nla_data(attr);
962+
/* The first attribute is always 'OVS_DEC_TTL_ATTR_ACTION'. */
963+
struct nlattr *actions = nla_data(attr);
964964

965-
if (nla_len(dec_ttl_arg)) {
966-
struct nlattr *actions = nla_data(dec_ttl_arg);
965+
if (nla_len(actions))
966+
return clone_execute(dp, skb, key, 0, nla_data(actions),
967+
nla_len(actions), last, false);
967968

968-
if (actions)
969-
return clone_execute(dp, skb, key, 0, nla_data(actions),
970-
nla_len(actions), last, false);
971-
}
972969
consume_skb(skb);
973970
return 0;
974971
}
@@ -1212,7 +1209,7 @@ static int execute_dec_ttl(struct sk_buff *skb, struct sw_flow_key *key)
12121209
return -EHOSTUNREACH;
12131210

12141211
key->ip.ttl = --nh->hop_limit;
1215-
} else {
1212+
} else if (skb->protocol == htons(ETH_P_IP)) {
12161213
struct iphdr *nh;
12171214
u8 old_ttl;
12181215

0 commit comments

Comments
 (0)