diff options
author | julian <julian@FreeBSD.org> | 2004-06-26 22:24:16 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2004-06-26 22:24:16 +0000 |
commit | 5a269c8a7e26638b8f896d1601618e5253776958 (patch) | |
tree | 5db990cf15727892f404908f26b492b9f1b8a509 /sys/netgraph/ng_ppp.c | |
parent | cb255821c823542b64070fb2864196922202a027 (diff) | |
download | FreeBSD-src-5a269c8a7e26638b8f896d1601618e5253776958.zip FreeBSD-src-5a269c8a7e26638b8f896d1601618e5253776958.tar.gz |
Having moved metadata usage to mbuf tags, remove code that supports
the old way of doing it.
Submitted by: Gleb Smirnoff <glebius@cell.sick.ru>
Diffstat (limited to 'sys/netgraph/ng_ppp.c')
-rw-r--r-- | sys/netgraph/ng_ppp.c | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index d5d0e52..26be68f 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -138,7 +138,6 @@ struct ng_ppp_frag { u_char last; /* Last in packet? */ struct timeval timestamp; /* time of reception */ struct mbuf *data; /* Fragment data */ - meta_p meta; /* Fragment meta */ TAILQ_ENTRY(ng_ppp_frag) f_qent; /* Fragment queue */ }; @@ -227,13 +226,13 @@ static int ng_ppp_output(node_p node, int bypass, int proto, int linkNum, item_p item); static int ng_ppp_mp_input(node_p node, int linkNum, item_p item); static int ng_ppp_check_packet(node_p node); -static void ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap); +static void ng_ppp_get_packet(node_p node, struct mbuf **mp); static int ng_ppp_frag_process(node_p node); static int ng_ppp_frag_trim(node_p node); static void ng_ppp_frag_timeout(void *arg); static void ng_ppp_frag_checkstale(node_p node); static void ng_ppp_frag_reset(node_p node); -static int ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta); +static int ng_ppp_mp_output(node_p node, struct mbuf *m); static void ng_ppp_mp_strategy(node_p node, int len, int *distrib); static int ng_ppp_intcmp(const void *v1, const void *v2); static struct mbuf *ng_ppp_addproto(struct mbuf *m, int proto, int compOK); @@ -1003,12 +1002,9 @@ ng_ppp_output(node_p node, int bypass, /* Special handling for the MP virtual link */ if (linkNum == NG_PPP_BUNDLE_LINKNUM) { - meta_p meta; - - /* strip off and discard the queue item */ - NGI_GET_META(item, meta); + /* discard the queue item */ NG_FREE_ITEM(item); - return ng_ppp_mp_output(node, m, meta); + return ng_ppp_mp_output(node, m); } /* Prepend address and control field (unless compressed) */ @@ -1094,10 +1090,8 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) struct ng_ppp_frag *qent; int i, diff, inserted; struct mbuf *m; - meta_p meta; NGI_GET_M(item, m); - NGI_GET_META(item, meta); NG_FREE_ITEM(item); /* Stats */ priv->bundleStats.recvFrames++; @@ -1110,13 +1104,11 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) if (m->m_pkthdr.len < 2) { link->stats.runts++; NG_FREE_M(m); - NG_FREE_META(meta); return (EINVAL); } - if (m->m_len < 2 && (m = m_pullup(m, 2)) == NULL) { - NG_FREE_META(meta); + if (m->m_len < 2 && (m = m_pullup(m, 2)) == NULL) return (ENOBUFS); - } + shdr = ntohs(*mtod(m, u_int16_t *)); frag->seq = MP_SHORT_EXTEND(shdr); frag->first = (shdr & MP_SHORT_FIRST_FLAG) != 0; @@ -1129,13 +1121,11 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) if (m->m_pkthdr.len < 4) { link->stats.runts++; NG_FREE_M(m); - NG_FREE_META(meta); return (EINVAL); } - if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL) { - NG_FREE_META(meta); + if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL) return (ENOBUFS); - } + lhdr = ntohl(*mtod(m, u_int32_t *)); frag->seq = MP_LONG_EXTEND(lhdr); frag->first = (lhdr & MP_LONG_FIRST_FLAG) != 0; @@ -1144,7 +1134,6 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) m_adj(m, 4); } frag->data = m; - frag->meta = meta; getmicrouptime(&frag->timestamp); /* If sequence number is < MSEQ, we've already declared this @@ -1152,7 +1141,6 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) if (diff < 0) { link->stats.dropFragments++; NG_FREE_M(m); - NG_FREE_META(meta); return (0); } @@ -1170,7 +1158,6 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) MALLOC(frag, struct ng_ppp_frag *, sizeof(*frag), M_NETGRAPH_PPP, M_NOWAIT); if (frag == NULL) { NG_FREE_M(m); - NG_FREE_META(meta); ng_ppp_frag_process(node); return (ENOMEM); } @@ -1187,7 +1174,6 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item) } else if (diff == 0) { /* should never happen! */ link->stats.dupFragments++; NG_FREE_M(frag->data); - NG_FREE_META(frag->meta); FREE(frag, M_NETGRAPH_PPP); return (EINVAL); } @@ -1239,7 +1225,7 @@ ng_ppp_check_packet(node_p node) * This assumes there is a completed packet there to pull off. */ static void -ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap) +ng_ppp_get_packet(node_p node, struct mbuf **mp) { const priv_p priv = NG_NODE_PRIVATE(node); struct ng_ppp_frag *qent, *qnext; @@ -1253,13 +1239,11 @@ ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap) KASSERT(!TAILQ_EMPTY(&priv->frags), ("%s: empty q", __func__)); TAILQ_REMOVE(&priv->frags, qent, f_qent); - if (tail == NULL) { + if (tail == NULL) tail = m = qent->data; - *metap = qent->meta; /* inherit first frag's meta */ - } else { + else { m->m_pkthdr.len += qent->data->m_pkthdr.len; tail->m_next = qent->data; - NG_FREE_META(qent->meta); /* drop other frags' metas */ } while (tail->m_next != NULL) tail = tail->m_next; @@ -1314,7 +1298,6 @@ ng_ppp_frag_trim(node_p node) priv->bundleStats.dropFragments++; TAILQ_REMOVE(&priv->frags, qent, f_qent); NG_FREE_M(qent->data); - NG_FREE_META(qent->meta); FREE(qent, M_NETGRAPH_PPP); priv->qlen--; removed = 1; @@ -1331,21 +1314,20 @@ ng_ppp_frag_process(node_p node) { const priv_p priv = NG_NODE_PRIVATE(node); struct mbuf *m; - meta_p meta; item_p item; /* Deliver any deliverable packets */ while (ng_ppp_check_packet(node)) { - ng_ppp_get_packet(node, &m, &meta); - item = ng_package_data(m, meta); + ng_ppp_get_packet(node, &m); + item = ng_package_data(m, NULL); ng_ppp_input(node, 0, NG_PPP_BUNDLE_LINKNUM, item); } /* Delete dead fragments and try again */ if (ng_ppp_frag_trim(node)) { while (ng_ppp_check_packet(node)) { - ng_ppp_get_packet(node, &m, &meta); - item = ng_package_data(m, meta); + ng_ppp_get_packet(node, &m); + item = ng_package_data(m, NULL); ng_ppp_input(node, 0, NG_PPP_BUNDLE_LINKNUM, item); } } @@ -1380,7 +1362,6 @@ ng_ppp_frag_process(node_p node) priv->bundleStats.dropFragments++; TAILQ_REMOVE(&priv->frags, qent, f_qent); NG_FREE_M(qent->data); - NG_FREE_META(qent->meta); FREE(qent, M_NETGRAPH_PPP); priv->qlen--; @@ -1411,7 +1392,6 @@ ng_ppp_frag_checkstale(node_p node) struct ng_ppp_frag *qent, *beg, *end; struct timeval now, age; struct mbuf *m; - meta_p meta; int i, seq; item_p item; int endseq; @@ -1459,14 +1439,13 @@ ng_ppp_frag_checkstale(node_p node) priv->bundleStats.dropFragments++; TAILQ_REMOVE(&priv->frags, qent, f_qent); NG_FREE_M(qent->data); - NG_FREE_META(qent->meta); FREE(qent, M_NETGRAPH_PPP); priv->qlen--; } /* Extract completed packet */ endseq = end->seq; - ng_ppp_get_packet(node, &m, &meta); + ng_ppp_get_packet(node, &m); /* Bump MSEQ if necessary */ if (MP_RECV_SEQ_DIFF(priv, priv->mseq, endseq) < 0) { @@ -1482,7 +1461,7 @@ ng_ppp_frag_checkstale(node_p node) } /* Deliver packet */ - item = ng_package_data(m, meta); + item = ng_package_data(m, NULL); ng_ppp_input(node, 0, NG_PPP_BUNDLE_LINKNUM, item); } } @@ -1523,7 +1502,7 @@ ng_ppp_frag_timeout(void *arg) * the frame across the individual PPP links and do so. */ static int -ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta) +ng_ppp_mp_output(node_p node, struct mbuf *m) { const priv_p priv = NG_NODE_PRIVATE(node); const int hdr_len = priv->conf.xmitShortSeq ? 2 : 4; @@ -1535,7 +1514,6 @@ ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta) /* At least one link must be active */ if (priv->numActiveLinks == 0) { NG_FREE_M(m); - NG_FREE_META(meta); return (ENETDOWN); } @@ -1581,7 +1559,6 @@ deliver: for ( ; distrib[activeLinkNum] > 0; firstFragment = 0) { int len, lastFragment, error; struct mbuf *m2; - meta_p meta2; /* Calculate fragment length; don't exceed link MTU */ len = distrib[activeLinkNum]; @@ -1597,7 +1574,6 @@ deliver: if (n == NULL) { NG_FREE_M(m); - NG_FREE_META(meta); return (ENOMEM); } m = n; @@ -1632,21 +1608,15 @@ deliver: if (m2 == NULL) { if (!lastFragment) m_freem(m); - NG_FREE_META(meta); return (ENOBUFS); } - /* Copy the meta information, if any */ - meta2 = lastFragment ? meta : ng_copy_meta(meta); - /* Send fragment */ - item = ng_package_data(m2, meta2); + item = ng_package_data(m2, NULL); error = ng_ppp_output(node, 0, PROT_MP, linkNum, item); if (error != 0) { - if (!lastFragment) { + if (!lastFragment) NG_FREE_M(m); - NG_FREE_META(meta); - } return (error); } } @@ -2056,7 +2026,6 @@ ng_ppp_frag_reset(node_p node) for (qent = TAILQ_FIRST(&priv->frags); qent; qent = qnext) { qnext = TAILQ_NEXT(qent, f_qent); NG_FREE_M(qent->data); - NG_FREE_META(qent->meta); FREE(qent, M_NETGRAPH_PPP); } TAILQ_INIT(&priv->frags); |