summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@cvs.openbsd.org>2016-12-02 17:06:14 +0000
committerRafael Zalamena <rzalamena@cvs.openbsd.org>2016-12-02 17:06:14 +0000
commitc2f15351f61fd85c7e393846d786b5ba8d492a17 (patch)
tree2d0cbd2d0609701e6f2f5c3e870b5259386cb8ee /sys/net
parent4ddefc2380b04e562369d912d548dd629eb9f4cf (diff)
Use the right variable for storing the maximum group table size and use
it to limit the amount of installable groups.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/switchofp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/net/switchofp.c b/sys/net/switchofp.c
index f1aff0b52ca..f299eae1d30 100644
--- a/sys/net/switchofp.c
+++ b/sys/net/switchofp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchofp.c,v 1.41 2016/12/02 10:07:47 rzalamena Exp $ */
+/* $OpenBSD: switchofp.c,v 1.42 2016/12/02 17:06:13 rzalamena Exp $ */
/*
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
@@ -973,7 +973,7 @@ swofp_create(struct switch_softc *sc)
timeout_add_sec(&swofs->swofs_flow_timeout, 10);
/* TODO: Configured from ifconfig */
- swofs->swofs_group_table_num = 1000;
+ swofs->swofs_group_max_table = 1000;
swofs->swofs_flow_max_entry = 10000;
sc->sc_capabilities |= SWITCH_CAP_OFP;
@@ -1073,7 +1073,7 @@ swofp_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data)
bparam->ifbrp_maxflow = swofs->swofs_flow_max_entry;
break;
case SIOCSWGMAXGROUP:
- bparam->ifbrp_maxgroup = swofs->swofs_group_table_num;
+ bparam->ifbrp_maxgroup = swofs->swofs_group_max_table;
break;
case SIOCSWSPORTNO:
if ((error = suser(curproc, 0)) != 0)
@@ -5180,12 +5180,18 @@ swofp_flow_mod(struct switch_softc *sc, struct mbuf *m)
int
swofp_group_mod_add(struct switch_softc *sc, struct mbuf *m)
{
+ struct swofp_ofs *ofs = sc->sc_ofs;
struct ofp_group_mod *ogm;
struct swofp_group_entry *swge;
int error;
ogm = mtod(m, struct ofp_group_mod *);
+ if (ofs->swofs_group_table_num >= ofs->swofs_group_max_table) {
+ error = OFP_ERRGROUPMOD_OUT_OF_GROUPS;
+ goto failed;
+ }
+
if (ntohl(ogm->gm_group_id) > OFP_GROUP_ID_MAX) {
error = OFP_ERRGROUPMOD_INVALID_GROUP;
goto failed;