diff options
| author | Gleb Smirnoff <glebius@FreeBSD.org> | 2014-10-31 16:00:45 +0000 |
|---|---|---|
| committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2014-10-31 16:00:45 +0000 |
| commit | 3a4c61c2fddb460ae25a243fb3d029562b5e5538 (patch) | |
| tree | 8226ede9fb7940b361dd83e5d5328d81607d1817 /sys/netgraph | |
| parent | 1d904a55c857399ee67c3182819e349f9e32f3a5 (diff) | |
Notes
Diffstat (limited to 'sys/netgraph')
| -rw-r--r-- | sys/netgraph/ng_frame_relay.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/sys/netgraph/ng_frame_relay.c b/sys/netgraph/ng_frame_relay.c index 4d39d11e1b63..a4a84fe37c3f 100644 --- a/sys/netgraph/ng_frame_relay.c +++ b/sys/netgraph/ng_frame_relay.c @@ -148,6 +148,8 @@ static struct ng_type typestruct = { }; NETGRAPH_INIT(framerelay, &typestruct); +#define ERROUT(x) do { error = (x); goto done; } while (0) + /* * Given a DLCI, return the index of the context table entry for it, * Allocating a new one if needs be, or -1 if none available. @@ -335,10 +337,8 @@ ngfrm_rcvdata(hook_p hook, item_p item) char *data; /* Data doesn't come in from just anywhere (e.g debug hook) */ - if (ctxp == NULL) { - error = ENETDOWN; - goto bad; - } + if (ctxp == NULL) + ERROUT(ENETDOWN); /* If coming from downstream, decode it to a channel */ dlci = ctxp->dlci; @@ -351,20 +351,16 @@ ngfrm_rcvdata(hook_p hook, item_p item) /* If there is no live channel, throw it away */ if ((sc->downstream.hook == NULL) - || ((ctxp->flags & CHAN_ACTIVE) == 0)) { - error = ENETDOWN; - goto bad; - } + || ((ctxp->flags & CHAN_ACTIVE) == 0)) + ERROUT(ENETDOWN); /* Store the DLCI on the front of the packet */ alen = sc->addrlen; if (alen == 0) alen = 2; /* default value for transmit */ M_PREPEND(m, alen, M_NOWAIT); - if (m == NULL) { - error = ENOBUFS; - goto bad; - } + if (m == NULL) + ERROUT(ENOBUFS); data = mtod(m, char *); /* @@ -401,7 +397,7 @@ ngfrm_rcvdata(hook_p hook, item_p item) NG_FWD_NEW_DATA(error, item, sc->downstream.hook, m); return (error); -bad: +done: NG_FREE_ITEM(item); NG_FREE_M(m); return (error); @@ -422,10 +418,8 @@ ngfrm_decode(node_p node, item_p item) struct mbuf *m; NGI_GET_M(item, m); - if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL) { - error = ENOBUFS; - goto out; - } + if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL) + ERROUT(ENOBUFS); data = mtod(m, char *); if ((alen = sc->addrlen) == 0) { sc->addrlen = alen = ngfrm_addrlen(data); @@ -447,14 +441,11 @@ ngfrm_decode(node_p node, item_p item) SHIFTIN(makeup + 3, data[3], dlci); break; default: - error = EINVAL; - goto out; + ERROUT(EINVAL); } - if (dlci > 1023) { - error = EINVAL; - goto out; - } + if (dlci > 1023) + ERROUT(EINVAL); ctxnum = sc->ALT[dlci]; if ((ctxnum & CTX_VALID) && sc->channel[ctxnum &= CTX_VALUE].hook) { /* Send it */ @@ -464,7 +455,7 @@ ngfrm_decode(node_p node, item_p item) } else { error = ENETDOWN; } -out: +done: NG_FREE_ITEM(item); NG_FREE_M(m); return (error); |
