From: Ben Pfaff Date: Tue, 5 Aug 2008 20:51:29 +0000 (-0700) Subject: Don't allow unsupported flags to be set in the switch. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8effb451ebd5312865b8adad2db767ffd97444ba;p=openvswitch Don't allow unsupported flags to be set in the switch. --- diff --git a/datapath/forward.c b/datapath/forward.c index 4dee840b..7167fbfc 100644 --- a/datapath/forward.c +++ b/datapath/forward.c @@ -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; diff --git a/switch/datapath.c b/switch/datapath.c index 4391634b..13d06ff1 100644 --- a/switch/datapath.c +++ b/switch/datapath.c @@ -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; }