summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@cvs.openbsd.org>2016-11-21 19:29:29 +0000
committerRafael Zalamena <rzalamena@cvs.openbsd.org>2016-11-21 19:29:29 +0000
commitc49215b37abb53e1864530f07d72896fc5dfb0c7 (patch)
tree193d9484c15a8eb8fc7c30a3789fa1c08a45008b /sys
parent39a0e6c0dd036a1306aa1a3628470e54ae0d4f15 (diff)
Simplify pad calculation for flow match on swofp_put_flow().
ok reyk@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/switchofp.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/net/switchofp.c b/sys/net/switchofp.c
index ddfc5bab523..07164af1585 100644
--- a/sys/net/switchofp.c
+++ b/sys/net/switchofp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchofp.c,v 1.35 2016/11/21 08:28:19 rzalamena Exp $ */
+/* $OpenBSD: switchofp.c,v 1.36 2016/11/21 19:29:28 rzalamena Exp $ */
/*
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
@@ -5647,6 +5647,7 @@ swofp_put_flow(struct mbuf *m, struct swofp_flow_table *swft,
const uint8_t pad_data[OFP_ALIGNMENT] = {};
struct mbuf *n;
int start, off, error, offp, pad = 0;
+ int omlen;
memset(&ofs, 0, sizeof(ofs));
@@ -5679,13 +5680,11 @@ swofp_put_flow(struct mbuf *m, struct swofp_flow_table *swft,
/*
* Put ofp_match include ofp_ox_matches and pad
*/
- if ((ntohs(swfe->swfe_match->om_length) % OFP_ALIGNMENT))
- pad = (OFP_ALIGNMENT -
- (ntohs(swfe->swfe_match->om_length) % OFP_ALIGNMENT));
- if ((error = m_copyback(m, off, ntohs(swfe->swfe_match->om_length),
- swfe->swfe_match, M_NOWAIT)))
+ omlen = ntohs(swfe->swfe_match->om_length);
+ pad = OFP_ALIGN(omlen) - omlen;
+ if ((error = m_copyback(m, off, omlen, swfe->swfe_match, M_NOWAIT)))
goto failed;
- off += ntohs(swfe->swfe_match->om_length);
+ off += omlen;
if ((error = m_copyback(m, off, pad, pad_data, M_NOWAIT)))
goto failed;
off += pad;