diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-17 13:10:27 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-17 13:10:27 +0000 |
commit | 8c8c9ac6a4261bb145477a92e503fc57f5c700ba (patch) | |
tree | 58db81df39a2c1a2a87b3801f2d2b9b14fc3f7f1 /usr.sbin/switchd | |
parent | d6a5d814dc7c368cdb5a8397237c4de9e5738eb1 (diff) |
In oflowmod, automatically open the instructions block with the first
instruction. This allows to make the grammar more flexible.
Diffstat (limited to 'usr.sbin/switchd')
-rw-r--r-- | usr.sbin/switchd/ofp_common.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/switchd/ofp_common.c b/usr.sbin/switchd/ofp_common.c index 765ca9d31bf..019f3c652ca 100644 --- a/usr.sbin/switchd/ofp_common.c +++ b/usr.sbin/switchd/ofp_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp_common.c,v 1.6 2016/11/17 12:40:56 reyk Exp $ */ +/* $OpenBSD: ofp_common.c,v 1.7 2016/11/17 13:10:26 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -1096,8 +1096,10 @@ oflowmod_iopen(struct oflowmod_ctx *ctx) struct ibuf *ibuf = ctx->ctx_ibuf; if (ctx->ctx_state < OFMCTX_MOPEN && - (oflowmod_mopen(ctx) == -1 || - oflowmod_mclose(ctx) == -1)) + (oflowmod_mopen(ctx) == -1)) + return (oflowmod_err(ctx, __func__, __LINE__)); + if (ctx->ctx_state < OFMCTX_MCLOSE && + (oflowmod_mclose(ctx) == -1)) return (oflowmod_err(ctx, __func__, __LINE__)); if (oflowmod_state(ctx, OFMCTX_MCLOSE, OFMCTX_IOPEN) == -1) @@ -1115,6 +1117,10 @@ oflowmod_instruction(struct oflowmod_ctx *ctx, unsigned int type) struct ofp_instruction *oi; size_t len; + if (ctx->ctx_state < OFMCTX_IOPEN && + (oflowmod_iopen(ctx) == -1)) + return (oflowmod_err(ctx, __func__, __LINE__)); + if (oflowmod_state(ctx, OFMCTX_IOPEN, OFMCTX_IOPEN) == -1) return (oflowmod_err(ctx, __func__, __LINE__)); |