summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@cvs.openbsd.org>2016-10-28 16:40:14 +0000
committerRafael Zalamena <rzalamena@cvs.openbsd.org>2016-10-28 16:40:14 +0000
commit8f79100ea56ac765a9284adeb4792b19f732f251 (patch)
tree95d8ce1daeb3d8b11e9f0076213d7de45c7741d4
parent19c99dfb93dc991362dc7c027817889c368516b9 (diff)
Change swofp_flow_table_add() malloc() behaviour to be non-blocking like
all others that we can find in switch(4). ok reyk@
-rw-r--r--sys/net/switchofp.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/net/switchofp.c b/sys/net/switchofp.c
index f3c546cdac7..b41c1a69375 100644
--- a/sys/net/switchofp.c
+++ b/sys/net/switchofp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchofp.c,v 1.19 2016/10/28 16:06:52 rzalamena Exp $ */
+/* $OpenBSD: switchofp.c,v 1.20 2016/10/28 16:40:13 rzalamena Exp $ */
/*
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
@@ -1238,9 +1238,10 @@ swofp_flow_table_add(struct switch_softc *sc, uint16_t table_id)
if ((swft = swofp_flow_table_lookup(sc, table_id)) != NULL)
return (swft);
- new = malloc(sizeof(*new), M_DEVBUF, M_WAITOK|M_ZERO);
- new->swft_table_id = table_id;
+ if ((new = malloc(sizeof(*new), M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
+ return (NULL);
+ new->swft_table_id = table_id;
TAILQ_FOREACH(swft, &ofs->swofs_table_list, swft_table_next) {
if (table_id < swft->swft_table_id)
break;
@@ -4662,8 +4663,10 @@ swofp_flow_mod_cmd_add(struct switch_softc *sc, struct mbuf *m)
goto ofp_error;
}
- if ((swft = swofp_flow_table_lookup(sc, ofm->fm_table_id)) == NULL)
- swft = swofp_flow_table_add(sc, ofm->fm_table_id);
+ if ((swft = swofp_flow_table_add(sc, ofm->fm_table_id)) == NULL) {
+ error = OFP_ERRFLOWMOD_TABLE_ID;
+ goto ofp_error;
+ }
if ((old_swfe = swofp_flow_search_by_table(swft, om,
ntohs(ofm->fm_priority)))) {