Commit 4bee42 "tunnel: Correctly check for internal device." fixed
the call to internal_dev_get_vport() by first checking that the
device is in fact an internal device. However, it also accidentally
removed the check ensuring that the vport itself was not NULL. This
adds that check back by redoing the previous change in a more robust
manner.
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
if (likely(cache)) {
int orig_len = skb->len - cache->len;
+ struct vport *cache_vport = internal_dev_get_vport(rt_dst(rt).dev);
skb->protocol = htons(ETH_P_IP);
iph->tot_len = htons(skb->len - skb_network_offset(skb));
ip_send_check(iph);
- if (is_internal_dev(rt_dst(rt).dev)) {
+ if (cache_vport) {
OVS_CB(skb)->flow = cache->flow;
compute_ip_summed(skb, true);
- vport_receive(internal_dev_get_vport(rt_dst(rt).dev), skb);
+ vport_receive(cache_vport, skb);
sent_len += orig_len;
} else {
int err;
struct vport *internal_dev_get_vport(struct net_device *netdev)
{
- struct internal_dev *internal_dev = internal_dev_priv(netdev);
+ struct internal_dev *internal_dev;
+
+ if (!is_internal_dev(netdev))
+ return NULL;
+
+ internal_dev = internal_dev_priv(netdev);
return rcu_dereference(internal_dev->attached_vport);
}