Don't allow unsupported flags to be set in the switch.
authorBen Pfaff <blp@nicira.com>
Tue, 5 Aug 2008 20:51:29 +0000 (13:51 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 7 Aug 2008 17:34:37 +0000 (10:34 -0700)
datapath/forward.c
switch/datapath.c

index 4dee840b48e03ad1f27cd5673b302b199e4f06cc..7167fbfc76883112e09b5ab9ebec6ddc7847e460 100644 (file)
@@ -306,8 +306,15 @@ recv_set_config(struct sw_chain *chain, const struct sender *sender,
                const void *msg)
 {
        const struct ofp_switch_config *osc = msg;
+       int flags;
+
+       flags = ntohs(osc->flags) & ~(OFPC_SEND_FLOW_EXP | OFPC_FRAG_MASK);
+       if ((flags & OFPC_FRAG_MASK) != OFPC_FRAG_NORMAL
+           && (flags & OFPC_FRAG_MASK) != OFPC_FRAG_DROP) {
+               flags = (flags & ~OFPC_FRAG_MASK) | OFPC_FRAG_DROP;
+       }
+       chain->dp->flags = flags;
 
-       chain->dp->flags = ntohs(osc->flags);
        chain->dp->miss_send_len = ntohs(osc->miss_send_len);
 
        return 0;
index 4391634bdb78614abaff27535dc881af8f33b2cd..13d06ff1d3c07a12352efa0686a82b8c31c5125d 100644 (file)
@@ -983,7 +983,14 @@ recv_set_config(struct datapath *dp, const struct sender *sender UNUSED,
                 const void *msg)
 {
     const struct ofp_switch_config *osc = msg;
-    dp->flags = ntohs(osc->flags);
+    int flags;
+
+    flags = ntohs(osc->flags) & ~(OFPC_SEND_FLOW_EXP | OFPC_FRAG_MASK);
+    if ((flags & OFPC_FRAG_MASK) != OFPC_FRAG_NORMAL
+        && (flags & OFPC_FRAG_MASK) != OFPC_FRAG_DROP) {
+        flags = (flags & ~OFPC_FRAG_MASK) | OFPC_FRAG_DROP;
+    }
+    dp->flags = flags;
     dp->miss_send_len = ntohs(osc->miss_send_len);
     return 0;
 }