Skip to content

Commit

Permalink
datapath: Initialize tunnel_key pad member.
Browse files Browse the repository at this point in the history
When a packet is received on a tunnel the pad member is currently
left uninitialized.  This didn't previously cause problems because
userspace didn't interprete the IPV4_TUNNEL attribute and blindly
copied back the uninitialized data.  However, now that userspace
knows how to serialize this attribute it was zeroing it out, which
prevented flows that had been previously installed from being
deleted.  In addition to zeroing out the padding on packet reception,
it also does the same thing on flow setup since we should be ignoring
the value.

Reported-by: Anand Krishnamurthy <[email protected]>
Reported-by: Saul St. John <[email protected]>
Signed-off-by: Jesse Gross <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
jessegross committed Dec 31, 2012
1 parent 39bbf1b commit 194254d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions datapath/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
return -EINVAL;

memcpy(&swkey->tun_key, tun_key, sizeof(swkey->tun_key));
memset(swkey->tun_key.pad, 0, sizeof(swkey->tun_key.pad));

attrs &= ~(1ULL << OVS_KEY_ATTR_TUN_ID);
attrs &= ~(1ULL << OVS_KEY_ATTR_IPV4_TUNNEL);
Expand All @@ -1064,6 +1065,7 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
return -EINVAL;

memcpy(&swkey->tun_key, tun_key, sizeof(swkey->tun_key));
memset(swkey->tun_key.pad, 0, sizeof(swkey->tun_key.pad));

attrs &= ~(1ULL << OVS_KEY_ATTR_IPV4_TUNNEL);
}
Expand Down
1 change: 1 addition & 0 deletions datapath/tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ static inline void tnl_tun_key_init(struct ovs_key_ipv4_tunnel *tun_key,
tun_key->ipv4_tos = iph->tos;
tun_key->ipv4_ttl = iph->ttl;
tun_key->tun_flags = tun_flags;
memset(tun_key->pad, 0, sizeof(tun_key->pad));
}

static inline void tnl_get_param(const struct tnl_mutable_config *mutable,
Expand Down

0 comments on commit 194254d

Please sign in to comment.