From 8effb451ebd5312865b8adad2db767ffd97444ba Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 5 Aug 2008 13:51:29 -0700 Subject: [PATCH] Don't allow unsupported flags to be set in the switch. --- datapath/forward.c | 9 ++++++++- switch/datapath.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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; } -- 2.30.2