13 #include <netlink-private/netlink.h>
14 #include <netlink-private/utils.h>
15 #include <netlink/netlink.h>
16 #include <netlink/utils.h>
17 #include <netlink/route/rtnl.h>
18 #include <netlink/route/neightbl.h>
19 #include <netlink/route/link.h>
22 #define NEIGHTBL_ATTR_FAMILY 0x001
23 #define NEIGHTBL_ATTR_STATS 0x002
24 #define NEIGHTBL_ATTR_NAME 0x004
25 #define NEIGHTBL_ATTR_THRESH1 0x008
26 #define NEIGHTBL_ATTR_THRESH2 0x010
27 #define NEIGHTBL_ATTR_THRESH3 0x020
28 #define NEIGHTBL_ATTR_CONFIG 0x040
29 #define NEIGHTBL_ATTR_PARMS 0x080
30 #define NEIGHTBL_ATTR_GC_INTERVAL 0x100
32 #define NEIGHTBLPARM_ATTR_IFINDEX 0x0001
33 #define NEIGHTBLPARM_ATTR_REFCNT 0x0002
34 #define NEIGHTBLPARM_ATTR_QUEUE_LEN 0x0004
35 #define NEIGHTBLPARM_ATTR_APP_PROBES 0x0008
36 #define NEIGHTBLPARM_ATTR_UCAST_PROBES 0x0010
37 #define NEIGHTBLPARM_ATTR_MCAST_PROBES 0x0020
38 #define NEIGHTBLPARM_ATTR_PROXY_QLEN 0x0040
39 #define NEIGHTBLPARM_ATTR_REACHABLE_TIME 0x0080
40 #define NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME 0x0100
41 #define NEIGHTBLPARM_ATTR_RETRANS_TIME 0x0200
42 #define NEIGHTBLPARM_ATTR_GC_STALETIME 0x0400
43 #define NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME 0x0800
44 #define NEIGHTBLPARM_ATTR_ANYCAST_DELAY 0x1000
45 #define NEIGHTBLPARM_ATTR_PROXY_DELAY 0x2000
46 #define NEIGHTBLPARM_ATTR_LOCKTIME 0x4000
48 static struct nl_cache_ops rtnl_neightbl_ops;
49 static struct nl_object_ops neightbl_obj_ops;
52 static uint64_t neightbl_compare(
struct nl_object *_a,
struct nl_object *_b,
53 uint64_t attrs,
int flags)
55 struct rtnl_neightbl *a = (
struct rtnl_neightbl *) _a;
56 struct rtnl_neightbl *b = (
struct rtnl_neightbl *) _b;
59 #define NT_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGHTBL_ATTR_##ATTR, a, b, EXPR)
61 diff |= NT_DIFF(FAMILY, a->nt_family != b->nt_family);
62 diff |= NT_DIFF(NAME, strcmp(a->nt_name, b->nt_name));
63 diff |= NT_DIFF(THRESH1, a->nt_gc_thresh1 != b->nt_gc_thresh1);
64 diff |= NT_DIFF(THRESH2, a->nt_gc_thresh2 != b->nt_gc_thresh2);
65 diff |= NT_DIFF(THRESH3, a->nt_gc_thresh3 != b->nt_gc_thresh3);
66 diff |= NT_DIFF(GC_INTERVAL, a->nt_gc_interval != b->nt_gc_interval);
70 if (!(a->ce_mask & NEIGHTBL_ATTR_PARMS) &&
71 !(b->ce_mask & NEIGHTBL_ATTR_PARMS))
78 #define REQ(F) (fp->ntp_mask & NEIGHTBLPARM_ATTR_##F)
79 #define AVAIL(F) (op->ntp_mask & NEIGHTBLPARM_ATTR_##F)
80 #define _C(F, N) (REQ(F) && (!AVAIL(F) || (op->N != fp->N)))
81 if (_C(IFINDEX, ntp_ifindex) ||
82 _C(QUEUE_LEN, ntp_queue_len) ||
83 _C(APP_PROBES, ntp_app_probes) ||
84 _C(UCAST_PROBES, ntp_ucast_probes) ||
85 _C(MCAST_PROBES, ntp_mcast_probes) ||
86 _C(PROXY_QLEN, ntp_proxy_qlen) ||
87 _C(LOCKTIME, ntp_locktime) ||
88 _C(RETRANS_TIME, ntp_retrans_time) ||
89 _C(BASE_REACHABLE_TIME, ntp_base_reachable_time) ||
90 _C(GC_STALETIME, ntp_gc_stale_time) ||
91 _C(DELAY_PROBE_TIME, ntp_probe_delay) ||
92 _C(ANYCAST_DELAY, ntp_anycast_delay) ||
93 _C(PROXY_DELAY, ntp_proxy_delay))
104 static struct nla_policy neightbl_policy[NDTA_MAX+1] = {
106 .maxlen = NTBLNAMSIZ },
107 [NDTA_THRESH1] = { .type =
NLA_U32 },
108 [NDTA_THRESH2] = { .type =
NLA_U32 },
109 [NDTA_THRESH3] = { .type =
NLA_U32 },
110 [NDTA_GC_INTERVAL] = { .type =
NLA_U32 },
111 [NDTA_CONFIG] = { .minlen =
sizeof(
struct ndt_config) },
112 [NDTA_STATS] = { .minlen =
sizeof(
struct ndt_stats) },
116 static int neightbl_msg_parser(
struct nl_cache_ops *ops,
117 struct sockaddr_nl *who,
struct nlmsghdr *n,
118 struct nl_parser_param *pp)
120 struct rtnl_neightbl *ntbl;
121 struct nlattr *tb[NDTA_MAX + 1];
122 struct rtgenmsg *rtmsg;
125 ntbl = rtnl_neightbl_alloc();
131 ntbl->ce_msgtype = n->nlmsg_type;
134 err =
nlmsg_parse(n,
sizeof(*rtmsg), tb, NDTA_MAX, neightbl_policy);
138 ntbl->nt_family = rtmsg->rtgen_family;
140 if (tb[NDTA_NAME] == NULL) {
141 err = -NLE_MISSING_ATTR;
145 nla_strlcpy(ntbl->nt_name, tb[NDTA_NAME], NTBLNAMSIZ);
146 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
148 if (tb[NDTA_THRESH1]) {
149 ntbl->nt_gc_thresh1 =
nla_get_u32(tb[NDTA_THRESH1]);
150 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
153 if (tb[NDTA_THRESH2]) {
154 ntbl->nt_gc_thresh2 =
nla_get_u32(tb[NDTA_THRESH2]);
155 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
158 if (tb[NDTA_THRESH3]) {
159 ntbl->nt_gc_thresh3 =
nla_get_u32(tb[NDTA_THRESH3]);
160 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
163 if (tb[NDTA_GC_INTERVAL]) {
164 ntbl->nt_gc_interval =
nla_get_u32(tb[NDTA_GC_INTERVAL]);
165 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
168 if (tb[NDTA_CONFIG]) {
170 sizeof(ntbl->nt_config));
171 ntbl->ce_mask |= NEIGHTBL_ATTR_CONFIG;
174 if (tb[NDTA_STATS]) {
176 sizeof(ntbl->nt_stats));
177 ntbl->ce_mask |= NEIGHTBL_ATTR_STATS;
180 if (tb[NDTA_PARMS]) {
181 struct nlattr *tbp[NDTPA_MAX + 1];
182 struct rtnl_neightbl_parms *p = &ntbl->nt_parms;
188 #define COPY_ENTRY(name, var) \
189 if (tbp[NDTPA_ ##name]) { \
190 p->ntp_ ##var = nla_get_u32(tbp[NDTPA_ ##name]); \
191 p->ntp_mask |= NEIGHTBLPARM_ATTR_ ##name; \
194 COPY_ENTRY(IFINDEX, ifindex);
195 COPY_ENTRY(REFCNT, refcnt);
196 COPY_ENTRY(QUEUE_LEN, queue_len);
197 COPY_ENTRY(APP_PROBES, app_probes);
198 COPY_ENTRY(UCAST_PROBES, ucast_probes);
199 COPY_ENTRY(MCAST_PROBES, mcast_probes);
200 COPY_ENTRY(PROXY_QLEN, proxy_qlen);
201 COPY_ENTRY(PROXY_DELAY, proxy_delay);
202 COPY_ENTRY(ANYCAST_DELAY, anycast_delay);
203 COPY_ENTRY(LOCKTIME, locktime);
204 COPY_ENTRY(REACHABLE_TIME, reachable_time);
205 COPY_ENTRY(BASE_REACHABLE_TIME, base_reachable_time);
206 COPY_ENTRY(RETRANS_TIME, retrans_time);
207 COPY_ENTRY(GC_STALETIME, gc_stale_time);
208 COPY_ENTRY(DELAY_PROBE_TIME, probe_delay);
211 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
214 err = pp->pp_cb((
struct nl_object *) ntbl, pp);
216 rtnl_neightbl_put(ntbl);
220 static int neightbl_request_update(
struct nl_cache *c,
struct nl_sock *h)
226 static void neightbl_dump_line(
struct nl_object *arg,
struct nl_dump_params *p)
228 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
230 nl_dump_line(p,
"%s", ntbl->nt_name);
232 if (ntbl->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX) {
233 struct nl_cache *link_cache;
241 ntbl->nt_parms.ntp_ifindex,
243 nl_cache_put(link_cache);
245 nl_dump(p,
"<%u> ", ntbl->nt_parms.ntp_ifindex);
249 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG)
250 nl_dump(p,
"entries %u ", ntbl->nt_config.ndtc_entries);
252 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
253 char rt[32], rt2[32];
254 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
256 nl_dump(p,
"reachable-time %s retransmit-time %s",
257 nl_msec2str(pa->ntp_reachable_time, rt,
sizeof(rt)),
258 nl_msec2str(pa->ntp_retrans_time, rt2,
sizeof(rt2)));
264 static void neightbl_dump_details(
struct nl_object *arg,
struct nl_dump_params *p)
266 char x[32], y[32], z[32];
267 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
269 neightbl_dump_line(arg, p);
271 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG) {
272 nl_dump_line(p,
" key-len %u entry-size %u last-flush %s\n",
273 ntbl->nt_config.ndtc_key_len,
274 ntbl->nt_config.ndtc_entry_size,
278 nl_dump_line(p,
" gc threshold %u/%u/%u interval %s " \
279 "chain-position %u\n",
280 ntbl->nt_gc_thresh1, ntbl->nt_gc_thresh2,
283 ntbl->nt_config.ndtc_hash_chain_gc);
285 nl_dump_line(p,
" hash-rand 0x%08X/0x%08X last-rand %s\n",
286 ntbl->nt_config.ndtc_hash_rnd,
287 ntbl->nt_config.ndtc_hash_mask,
292 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
293 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
295 nl_dump_line(p,
" refcnt %u pending-queue-limit %u " \
296 "proxy-delayed-queue-limit %u\n",
301 nl_dump_line(p,
" num-userspace-probes %u num-unicast-probes " \
302 "%u num-multicast-probes %u\n",
304 pa->ntp_ucast_probes,
305 pa->ntp_mcast_probes);
307 nl_dump_line(p,
" min-age %s base-reachable-time %s " \
308 "stale-check-interval %s\n",
314 nl_dump_line(p,
" initial-probe-delay %s answer-delay %s " \
315 "proxy-answer-delay %s\n",
322 static void neightbl_dump_stats(
struct nl_object *arg,
struct nl_dump_params *p)
324 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
326 neightbl_dump_details(arg, p);
328 if (!(ntbl->ce_mask & NEIGHTBL_ATTR_STATS))
331 nl_dump_line(p,
" " \
332 " lookups %" PRIu64 \
335 " allocations %" PRIu64 \
336 " destroys %" PRIu64 \
338 ntbl->nt_stats.ndts_lookups,
339 ntbl->nt_stats.ndts_hits,
340 ntbl->nt_stats.ndts_res_failed,
341 ntbl->nt_stats.ndts_allocs,
342 ntbl->nt_stats.ndts_destroys);
344 nl_dump_line(p,
" " \
345 " hash-grows %" PRIu64 \
346 " forced-gc-runs %" PRIu64 \
347 " periodic-gc-runs %" PRIu64 \
349 ntbl->nt_stats.ndts_hash_grows,
350 ntbl->nt_stats.ndts_forced_gc_runs,
351 ntbl->nt_stats.ndts_periodic_gc_runs);
353 nl_dump_line(p,
" " \
354 " rcv-unicast-probes %" PRIu64 \
355 " rcv-multicast-probes %" PRIu64 \
357 ntbl->nt_stats.ndts_rcv_probes_ucast,
358 ntbl->nt_stats.ndts_rcv_probes_mcast);
366 struct rtnl_neightbl *rtnl_neightbl_alloc(
void)
371 void rtnl_neightbl_put(
struct rtnl_neightbl *neightbl)
413 const char *name,
int ifindex)
415 struct rtnl_neightbl *nt;
417 if (cache->c_ops != &rtnl_neightbl_ops)
420 nl_list_for_each_entry(nt, &cache->c_items, ce_list) {
421 if (!strcasecmp(nt->nt_name, name) &&
422 ((!ifindex && !nt->nt_parms.ntp_ifindex) ||
423 (ifindex && ifindex == nt->nt_parms.ntp_ifindex))) {
456 struct rtnl_neightbl *tmpl,
457 struct nl_msg **result)
459 struct nl_msg *m, *parms = NULL;
460 struct ndtmsg ndt = {
461 .ndtm_family = old->nt_family,
468 if (
nlmsg_append(m, &ndt,
sizeof(ndt), NLMSG_ALIGNTO) < 0)
469 goto nla_put_failure;
473 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH1)
476 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
479 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
482 if (tmpl->ce_mask & NEIGHTBL_ATTR_GC_INTERVAL)
484 tmpl->nt_gc_interval);
486 if (tmpl->ce_mask & NEIGHTBL_ATTR_PARMS) {
487 struct rtnl_neightbl_parms *p = &tmpl->nt_parms;
491 goto nla_put_failure;
493 if (old->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX)
495 old->nt_parms.ntp_ifindex);
498 if (p->ntp_mask & NEIGHTBLPARM_ATTR_QUEUE_LEN)
499 NLA_PUT_U32(parms, NDTPA_QUEUE_LEN, p->ntp_queue_len);
501 if (p->ntp_mask & NEIGHTBLPARM_ATTR_APP_PROBES)
502 NLA_PUT_U32(parms, NDTPA_APP_PROBES, p->ntp_app_probes);
504 if (p->ntp_mask & NEIGHTBLPARM_ATTR_UCAST_PROBES)
506 p->ntp_ucast_probes);
508 if (p->ntp_mask & NEIGHTBLPARM_ATTR_MCAST_PROBES)
510 p->ntp_mcast_probes);
512 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_QLEN)
516 if (p->ntp_mask & NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME)
518 p->ntp_base_reachable_time);
520 if (p->ntp_mask & NEIGHTBLPARM_ATTR_RETRANS_TIME)
522 p->ntp_retrans_time);
524 if (p->ntp_mask & NEIGHTBLPARM_ATTR_GC_STALETIME)
526 p->ntp_gc_stale_time);
528 if (p->ntp_mask & NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME)
532 if (p->ntp_mask & NEIGHTBLPARM_ATTR_ANYCAST_DELAY)
534 p->ntp_anycast_delay);
536 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_DELAY)
540 if (p->ntp_mask & NEIGHTBLPARM_ATTR_LOCKTIME)
541 NLA_PUT_U64(parms, NDTPA_LOCKTIME, p->ntp_locktime);
544 goto nla_put_failure;
573 struct rtnl_neightbl *tmpl)
586 return wait_for_ack(sk);
596 void rtnl_neightbl_set_family(
struct rtnl_neightbl *ntbl,
int family)
598 ntbl->nt_family = family;
599 ntbl->ce_mask |= NEIGHTBL_ATTR_FAMILY;
602 void rtnl_neightbl_set_gc_interval(
struct rtnl_neightbl *ntbl, uint64_t ms)
604 ntbl->nt_gc_interval = ms;
605 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
608 void rtnl_neightbl_set_gc_tresh1(
struct rtnl_neightbl *ntbl,
int thresh)
610 ntbl->nt_gc_thresh1 = thresh;
611 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
614 void rtnl_neightbl_set_gc_tresh2(
struct rtnl_neightbl *ntbl,
int thresh)
616 ntbl->nt_gc_thresh2 = thresh;
617 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
620 void rtnl_neightbl_set_gc_tresh3(
struct rtnl_neightbl *ntbl,
int thresh)
622 ntbl->nt_gc_thresh3 = thresh;
623 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
626 void rtnl_neightbl_set_name(
struct rtnl_neightbl *ntbl,
const char *name)
628 _nl_strncpy_trunc(ntbl->nt_name, name,
sizeof(ntbl->nt_name));
629 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
632 void rtnl_neightbl_set_dev(
struct rtnl_neightbl *ntbl,
int ifindex)
634 ntbl->nt_parms.ntp_ifindex = ifindex;
635 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_IFINDEX;
636 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
646 ntbl->nt_parms.ntp_queue_len = len;
647 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_QUEUE_LEN;
648 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
658 ntbl->nt_parms.ntp_proxy_qlen = len;
659 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_QLEN;
660 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
670 ntbl->nt_parms.ntp_app_probes = probes;
671 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_APP_PROBES;
672 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
682 ntbl->nt_parms.ntp_ucast_probes = probes;
683 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_UCAST_PROBES;
684 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
694 ntbl->nt_parms.ntp_mcast_probes = probes;
695 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_MCAST_PROBES;
696 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
707 ntbl->nt_parms.ntp_base_reachable_time = ms;
708 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME;
709 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
719 ntbl->nt_parms.ntp_retrans_time = ms;
720 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_RETRANS_TIME;
721 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
731 ntbl->nt_parms.ntp_gc_stale_time = ms;
732 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_GC_STALETIME;
733 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
743 ntbl->nt_parms.ntp_probe_delay = ms;
744 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME;
745 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
755 ntbl->nt_parms.ntp_anycast_delay = ms;
756 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_ANYCAST_DELAY;
757 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
767 ntbl->nt_parms.ntp_proxy_delay = ms;
768 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_DELAY;
769 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
779 ntbl->nt_parms.ntp_locktime = ms;
780 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_LOCKTIME;
781 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
786 static struct nl_object_ops neightbl_obj_ops = {
787 .oo_name =
"route/neightbl",
788 .oo_size =
sizeof(
struct rtnl_neightbl),
794 .oo_compare = neightbl_compare,
797 static struct nl_cache_ops rtnl_neightbl_ops = {
798 .co_name =
"route/neightbl",
799 .co_hdrsize =
sizeof(
struct rtgenmsg),
801 { RTM_NEWNEIGHTBL, NL_ACT_NEW,
"new" },
802 { RTM_SETNEIGHTBL, NL_ACT_SET,
"set" },
803 { RTM_GETNEIGHTBL, NL_ACT_GET,
"get" },
804 END_OF_MSGTYPES_LIST,
806 .co_protocol = NETLINK_ROUTE,
807 .co_request_update = neightbl_request_update,
808 .co_msg_parser = neightbl_msg_parser,
809 .co_obj_ops = &neightbl_obj_ops,
812 static void __init neightbl_init(
void)
817 static void __exit neightbl_exit(
void)
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
int nla_put_nested(struct nl_msg *msg, int attrtype, const struct nl_msg *nested)
Add nested attributes to netlink message.
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
Copy string attribute payload to a buffer.
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, const struct nla_policy *policy)
Create attribute index based on nested attribute.
#define NLA_PUT_STRING(msg, attrtype, value)
Add string attribute to netlink message.
#define NLA_PUT_U64(msg, attrtype, value)
Add 64 bit integer attribute to netlink message.
@ NLA_STRING
NUL terminated character string.
@ NLA_NESTED
Nested attributes.
int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
Unregister a set of cache operations.
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
struct nl_cache * nl_cache_mngt_require_safe(const char *name)
Return cache previously provided via nl_cache_mngt_provide()
int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_sock *sock, struct nl_cache **result)
Allocate new cache and fill it.
char * rtnl_link_i2name(struct nl_cache *cache, int ifindex, char *dst, size_t len)
Translate interface index to corresponding link name.
struct nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
void nlmsg_free(struct nl_msg *msg)
Release a reference from an netlink message.
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy)
parse attributes of a netlink message
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
int nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
void rtnl_neightbl_set_proxy_delay(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the proxy delay of a neighbour table to the specified value.
struct rtnl_neightbl * rtnl_neightbl_get(struct nl_cache *cache, const char *name, int ifindex)
Lookup neighbour table by name and optional interface index.
int rtnl_neightbl_change(struct nl_sock *sk, struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
Change neighbour table attributes.
void rtnl_neightbl_set_locktime(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the locktime of a neighbour table to the specified value.
int rtnl_neightbl_build_change_request(struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl, struct nl_msg **result)
Builds a netlink change request message to change neighbour table attributes.
void rtnl_neightbl_set_gc_stale_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the gc stale time of a neighbour table to the specified value.
void rtnl_neightbl_set_queue_len(struct rtnl_neightbl *ntbl, int len)
Set the queue length for pending requests of a neighbour table to the specified value.
int rtnl_neightbl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
Build a neighbour table cache including all neighbour tables currently configured in the kernel.
void rtnl_neightbl_set_app_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of application probes of a neighbour table to the specified value.
void rtnl_neightbl_set_anycast_delay(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the anycast delay of a neighbour table to the specified value.
void rtnl_neightbl_set_delay_probe_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the first probe delay time of a neighbour table to the specified value.
void rtnl_neightbl_set_retrans_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the retransmit time of a neighbour table to the specified value.
void rtnl_neightbl_set_mcast_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of multicast probes of a neighbour table to the specified value.
void rtnl_neightbl_set_proxy_queue_len(struct rtnl_neightbl *ntbl, int len)
Set the queue length for delay proxy arp requests of a neighbour table to the specified value.
void rtnl_neightbl_set_base_reachable_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the base reachable time of a neighbour table to the specified value.
void rtnl_neightbl_set_ucast_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of unicast probes of a neighbour table to the specified value.
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
Send routing netlink request message.
int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
char * nl_msec2str(uint64_t msec, char *buf, size_t len)
Convert milliseconds to a character string.
@ NL_DUMP_STATS
Dump all attributes including statistics.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Attribute validation policy.
uint16_t type
Type of attribute or NLA_UNSPEC.