Unconditionally set skb->dev in dp_set_origin.
authorJustin Pettit <jpettit@nicira.com>
Mon, 6 Oct 2008 22:51:06 +0000 (15:51 -0700)
committerJustin Pettit <jpettit@nicira.com>
Mon, 6 Oct 2008 22:51:06 +0000 (15:51 -0700)
If an invalid port index was used in dp_set_origin, the value of skb->dev
was left unchanged.  This change causes skb->dev to be set to NULL in those
circumstances.  This makes Packet Out and Add Flow messages that use a
buffer id behave like Packet Out without a buffer id.

datapath/datapath.c
datapath/datapath.h

index d84240b..3fa8cdc 100644 (file)
@@ -533,17 +533,16 @@ output_all(struct datapath *dp, struct sk_buff *skb, int flood)
 
 /* Marks 'skb' as having originated from 'in_port' in 'dp'.
    FIXME: how are devices reference counted? */
-int dp_set_origin(struct datapath *dp, uint16_t in_port,
+void dp_set_origin(struct datapath *dp, uint16_t in_port,
                           struct sk_buff *skb)
 {
        struct net_bridge_port *p = (in_port < OFPP_MAX ? dp->ports[in_port]
                                     : in_port == OFPP_LOCAL ? dp->local_port
                                     : NULL);
-       if (p) {
+       if (p) 
                skb->dev = p->dev;
-               return 0;
-       }
-       return -ENOENT;
+        else 
+               skb->dev = NULL;
 }
 
 static int xmit_skb(struct sk_buff *skb)
index f5225e1..10a42c0 100644 (file)
@@ -90,7 +90,7 @@ int dp_output_port(struct datapath *, struct sk_buff *, int out_port,
                   int ignore_no_fwd);
 int dp_output_control(struct datapath *, struct sk_buff *, uint32_t, 
                        size_t, int);
-int dp_set_origin(struct datapath *, uint16_t, struct sk_buff *);
+void dp_set_origin(struct datapath *, uint16_t, struct sk_buff *);
 int dp_send_features_reply(struct datapath *, const struct sender *);
 int dp_send_config_reply(struct datapath *, const struct sender *);
 int dp_send_port_status(struct net_bridge_port *p, uint8_t status);