MCPcopy Create free account
hub / github.com/F-Stack/f-stack / get_export_dgram

Function get_export_dgram

freebsd/netgraph/netflow/netflow.c:168–197  ·  view source on GitHub ↗

* Detach export datagram from priv, if there is any. * If there is no, allocate a new one. */

Source from the content-addressed store, hash-verified

166 * If there is no, allocate a new one.
167 */
168static item_p
169get_export_dgram(priv_p priv, fib_export_p fe)
170{
171 item_p item = NULL;
172
173 mtx_lock(&fe->export_mtx);
174 if (fe->exp.item != NULL) {
175 item = fe->exp.item;
176 fe->exp.item = NULL;
177 }
178 mtx_unlock(&fe->export_mtx);
179
180 if (item == NULL) {
181 struct netflow_v5_export_dgram *dgram;
182 struct mbuf *m;
183
184 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
185 if (m == NULL)
186 return (NULL);
187 item = ng_package_data(m, NG_NOFLAGS);
188 if (item == NULL)
189 return (NULL);
190 dgram = mtod(m, struct netflow_v5_export_dgram *);
191 dgram->header.count = 0;
192 dgram->header.version = htons(NETFLOW_V5);
193 dgram->header.pad = 0;
194 }
195
196 return (item);
197}
198
199/*
200 * Re-attach incomplete datagram back to priv.

Callers 1

expire_flowFunction · 0.85

Calls 4

mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50
m_getclFunction · 0.50
ng_package_dataFunction · 0.50

Tested by

no test coverage detected