20 #include <netlink-private/netlink.h> 21 #include <netlink/netlink.h> 22 #include <netlink/utils.h> 23 #include <netlink/route/rtnl.h> 24 #include <netlink/route/neightbl.h> 25 #include <netlink/route/link.h> 28 #define NEIGHTBL_ATTR_FAMILY 0x001 29 #define NEIGHTBL_ATTR_STATS 0x002 30 #define NEIGHTBL_ATTR_NAME 0x004 31 #define NEIGHTBL_ATTR_THRESH1 0x008 32 #define NEIGHTBL_ATTR_THRESH2 0x010 33 #define NEIGHTBL_ATTR_THRESH3 0x020 34 #define NEIGHTBL_ATTR_CONFIG 0x040 35 #define NEIGHTBL_ATTR_PARMS 0x080 36 #define NEIGHTBL_ATTR_GC_INTERVAL 0x100 38 #define NEIGHTBLPARM_ATTR_IFINDEX 0x0001 39 #define NEIGHTBLPARM_ATTR_REFCNT 0x0002 40 #define NEIGHTBLPARM_ATTR_QUEUE_LEN 0x0004 41 #define NEIGHTBLPARM_ATTR_APP_PROBES 0x0008 42 #define NEIGHTBLPARM_ATTR_UCAST_PROBES 0x0010 43 #define NEIGHTBLPARM_ATTR_MCAST_PROBES 0x0020 44 #define NEIGHTBLPARM_ATTR_PROXY_QLEN 0x0040 45 #define NEIGHTBLPARM_ATTR_REACHABLE_TIME 0x0080 46 #define NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME 0x0100 47 #define NEIGHTBLPARM_ATTR_RETRANS_TIME 0x0200 48 #define NEIGHTBLPARM_ATTR_GC_STALETIME 0x0400 49 #define NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME 0x0800 50 #define NEIGHTBLPARM_ATTR_ANYCAST_DELAY 0x1000 51 #define NEIGHTBLPARM_ATTR_PROXY_DELAY 0x2000 52 #define NEIGHTBLPARM_ATTR_LOCKTIME 0x4000 54 static struct nl_cache_ops rtnl_neightbl_ops;
55 static struct nl_object_ops neightbl_obj_ops;
58 static uint64_t neightbl_compare(
struct nl_object *_a,
struct nl_object *_b,
59 uint64_t attrs,
int flags)
61 struct rtnl_neightbl *a = (
struct rtnl_neightbl *) _a;
62 struct rtnl_neightbl *b = (
struct rtnl_neightbl *) _b;
65 #define NT_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGHTBL_ATTR_##ATTR, a, b, EXPR) 67 diff |= NT_DIFF(FAMILY, a->nt_family != b->nt_family);
68 diff |= NT_DIFF(NAME, strcmp(a->nt_name, b->nt_name));
69 diff |= NT_DIFF(THRESH1, a->nt_gc_thresh1 != b->nt_gc_thresh1);
70 diff |= NT_DIFF(THRESH2, a->nt_gc_thresh2 != b->nt_gc_thresh2);
71 diff |= NT_DIFF(THRESH3, a->nt_gc_thresh3 != b->nt_gc_thresh3);
72 diff |= NT_DIFF(GC_INTERVAL, a->nt_gc_interval != b->nt_gc_interval);
76 if (!(a->ce_mask & NEIGHTBL_ATTR_PARMS) &&
77 !(b->ce_mask & NEIGHTBL_ATTR_PARMS))
84 #define REQ(F) (fp->ntp_mask & NEIGHTBLPARM_ATTR_##F) 85 #define AVAIL(F) (op->ntp_mask & NEIGHTBLPARM_ATTR_##F) 86 #define _C(F, N) (REQ(F) && (!AVAIL(F) || (op->N != fp->N))) 87 if (_C(IFINDEX, ntp_ifindex) ||
88 _C(QUEUE_LEN, ntp_queue_len) ||
89 _C(APP_PROBES, ntp_app_probes) ||
90 _C(UCAST_PROBES, ntp_ucast_probes) ||
91 _C(MCAST_PROBES, ntp_mcast_probes) ||
92 _C(PROXY_QLEN, ntp_proxy_qlen) ||
93 _C(LOCKTIME, ntp_locktime) ||
94 _C(RETRANS_TIME, ntp_retrans_time) ||
95 _C(BASE_REACHABLE_TIME, ntp_base_reachable_time) ||
96 _C(GC_STALETIME, ntp_gc_stale_time) ||
97 _C(DELAY_PROBE_TIME, ntp_probe_delay) ||
98 _C(ANYCAST_DELAY, ntp_anycast_delay) ||
99 _C(PROXY_DELAY, ntp_proxy_delay))
110 static struct nla_policy neightbl_policy[NDTA_MAX+1] = {
112 .maxlen = NTBLNAMSIZ },
113 [NDTA_THRESH1] = { .type =
NLA_U32 },
114 [NDTA_THRESH2] = { .type =
NLA_U32 },
115 [NDTA_THRESH3] = { .type =
NLA_U32 },
116 [NDTA_GC_INTERVAL] = { .type =
NLA_U32 },
117 [NDTA_CONFIG] = { .minlen =
sizeof(
struct ndt_config) },
118 [NDTA_STATS] = { .minlen =
sizeof(
struct ndt_stats) },
122 static int neightbl_msg_parser(
struct nl_cache_ops *ops,
123 struct sockaddr_nl *who,
struct nlmsghdr *n,
124 struct nl_parser_param *pp)
126 struct rtnl_neightbl *ntbl;
127 struct nlattr *tb[NDTA_MAX + 1];
128 struct rtgenmsg *rtmsg;
131 ntbl = rtnl_neightbl_alloc();
137 ntbl->ce_msgtype = n->nlmsg_type;
140 err =
nlmsg_parse(n,
sizeof(*rtmsg), tb, NDTA_MAX, neightbl_policy);
144 ntbl->nt_family = rtmsg->rtgen_family;
146 if (tb[NDTA_NAME] == NULL) {
147 err = -NLE_MISSING_ATTR;
151 nla_strlcpy(ntbl->nt_name, tb[NDTA_NAME], NTBLNAMSIZ);
152 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
154 if (tb[NDTA_THRESH1]) {
155 ntbl->nt_gc_thresh1 =
nla_get_u32(tb[NDTA_THRESH1]);
156 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
159 if (tb[NDTA_THRESH2]) {
160 ntbl->nt_gc_thresh2 =
nla_get_u32(tb[NDTA_THRESH2]);
161 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
164 if (tb[NDTA_THRESH3]) {
165 ntbl->nt_gc_thresh3 =
nla_get_u32(tb[NDTA_THRESH3]);
166 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
169 if (tb[NDTA_GC_INTERVAL]) {
170 ntbl->nt_gc_interval =
nla_get_u32(tb[NDTA_GC_INTERVAL]);
171 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
174 if (tb[NDTA_CONFIG]) {
176 sizeof(ntbl->nt_config));
177 ntbl->ce_mask |= NEIGHTBL_ATTR_CONFIG;
180 if (tb[NDTA_STATS]) {
182 sizeof(ntbl->nt_stats));
183 ntbl->ce_mask |= NEIGHTBL_ATTR_STATS;
186 if (tb[NDTA_PARMS]) {
187 struct nlattr *tbp[NDTPA_MAX + 1];
188 struct rtnl_neightbl_parms *p = &ntbl->nt_parms;
194 #define COPY_ENTRY(name, var) \ 195 if (tbp[NDTPA_ ##name]) { \ 196 p->ntp_ ##var = nla_get_u32(tbp[NDTPA_ ##name]); \ 197 p->ntp_mask |= NEIGHTBLPARM_ATTR_ ##name; \ 200 COPY_ENTRY(IFINDEX, ifindex);
201 COPY_ENTRY(REFCNT, refcnt);
202 COPY_ENTRY(QUEUE_LEN, queue_len);
203 COPY_ENTRY(APP_PROBES, app_probes);
204 COPY_ENTRY(UCAST_PROBES, ucast_probes);
205 COPY_ENTRY(MCAST_PROBES, mcast_probes);
206 COPY_ENTRY(PROXY_QLEN, proxy_qlen);
207 COPY_ENTRY(PROXY_DELAY, proxy_delay);
208 COPY_ENTRY(ANYCAST_DELAY, anycast_delay);
209 COPY_ENTRY(LOCKTIME, locktime);
210 COPY_ENTRY(REACHABLE_TIME, reachable_time);
211 COPY_ENTRY(BASE_REACHABLE_TIME, base_reachable_time);
212 COPY_ENTRY(RETRANS_TIME, retrans_time);
213 COPY_ENTRY(GC_STALETIME, gc_stale_time);
214 COPY_ENTRY(DELAY_PROBE_TIME, probe_delay);
217 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
220 err = pp->pp_cb((
struct nl_object *) ntbl, pp);
222 rtnl_neightbl_put(ntbl);
226 static int neightbl_request_update(
struct nl_cache *c,
struct nl_sock *h)
232 static void neightbl_dump_line(
struct nl_object *arg,
struct nl_dump_params *p)
234 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
236 nl_dump_line(p,
"%s", ntbl->nt_name);
238 if (ntbl->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX) {
239 struct nl_cache *link_cache;
247 ntbl->nt_parms.ntp_ifindex,
249 nl_cache_put(link_cache);
251 nl_dump(p,
"<%u> ", ntbl->nt_parms.ntp_ifindex);
255 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG)
256 nl_dump(p,
"entries %u ", ntbl->nt_config.ndtc_entries);
258 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
259 char rt[32], rt2[32];
260 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
262 nl_dump(p,
"reachable-time %s retransmit-time %s",
263 nl_msec2str(pa->ntp_reachable_time, rt,
sizeof(rt)),
264 nl_msec2str(pa->ntp_retrans_time, rt2,
sizeof(rt2)));
270 static void neightbl_dump_details(
struct nl_object *arg,
struct nl_dump_params *p)
272 char x[32], y[32], z[32];
273 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
275 neightbl_dump_line(arg, p);
277 if (ntbl->ce_mask & NEIGHTBL_ATTR_CONFIG) {
278 nl_dump_line(p,
" key-len %u entry-size %u last-flush %s\n",
279 ntbl->nt_config.ndtc_key_len,
280 ntbl->nt_config.ndtc_entry_size,
284 nl_dump_line(p,
" gc threshold %u/%u/%u interval %s " \
285 "chain-position %u\n",
286 ntbl->nt_gc_thresh1, ntbl->nt_gc_thresh2,
289 ntbl->nt_config.ndtc_hash_chain_gc);
291 nl_dump_line(p,
" hash-rand 0x%08X/0x%08X last-rand %s\n",
292 ntbl->nt_config.ndtc_hash_rnd,
293 ntbl->nt_config.ndtc_hash_mask,
298 if (ntbl->ce_mask & NEIGHTBL_ATTR_PARMS) {
299 struct rtnl_neightbl_parms *pa = &ntbl->nt_parms;
301 nl_dump_line(p,
" refcnt %u pending-queue-limit %u " \
302 "proxy-delayed-queue-limit %u\n",
307 nl_dump_line(p,
" num-userspace-probes %u num-unicast-probes " \
308 "%u num-multicast-probes %u\n",
310 pa->ntp_ucast_probes,
311 pa->ntp_mcast_probes);
313 nl_dump_line(p,
" min-age %s base-reachable-time %s " \
314 "stale-check-interval %s\n",
320 nl_dump_line(p,
" initial-probe-delay %s answer-delay %s " \
321 "proxy-answer-delay %s\n",
328 static void neightbl_dump_stats(
struct nl_object *arg,
struct nl_dump_params *p)
330 struct rtnl_neightbl *ntbl = (
struct rtnl_neightbl *) arg;
332 neightbl_dump_details(arg, p);
334 if (!(ntbl->ce_mask & NEIGHTBL_ATTR_STATS))
337 nl_dump_line(p,
" " \
338 " lookups %" PRIu64 \
341 " allocations %" PRIu64 \
342 " destroys %" PRIu64 \
344 ntbl->nt_stats.ndts_lookups,
345 ntbl->nt_stats.ndts_hits,
346 ntbl->nt_stats.ndts_res_failed,
347 ntbl->nt_stats.ndts_allocs,
348 ntbl->nt_stats.ndts_destroys);
350 nl_dump_line(p,
" " \
351 " hash-grows %" PRIu64 \
352 " forced-gc-runs %" PRIu64 \
353 " periodic-gc-runs %" PRIu64 \
355 ntbl->nt_stats.ndts_hash_grows,
356 ntbl->nt_stats.ndts_forced_gc_runs,
357 ntbl->nt_stats.ndts_periodic_gc_runs);
359 nl_dump_line(p,
" " \
360 " rcv-unicast-probes %" PRIu64 \
361 " rcv-multicast-probes %" PRIu64 \
363 ntbl->nt_stats.ndts_rcv_probes_ucast,
364 ntbl->nt_stats.ndts_rcv_probes_mcast);
372 struct rtnl_neightbl *rtnl_neightbl_alloc(
void)
377 void rtnl_neightbl_put(
struct rtnl_neightbl *neightbl)
419 const char *name,
int ifindex)
421 struct rtnl_neightbl *nt;
423 if (cache->c_ops != &rtnl_neightbl_ops)
426 nl_list_for_each_entry(nt, &cache->c_items, ce_list) {
427 if (!strcasecmp(nt->nt_name, name) &&
428 ((!ifindex && !nt->nt_parms.ntp_ifindex) ||
429 (ifindex && ifindex == nt->nt_parms.ntp_ifindex))) {
462 struct rtnl_neightbl *tmpl,
463 struct nl_msg **result)
465 struct nl_msg *m, *parms = NULL;
466 struct ndtmsg ndt = {
467 .ndtm_family = old->nt_family,
474 if (
nlmsg_append(m, &ndt,
sizeof(ndt), NLMSG_ALIGNTO) < 0)
475 goto nla_put_failure;
479 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH1)
482 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
485 if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
488 if (tmpl->ce_mask & NEIGHTBL_ATTR_GC_INTERVAL)
490 tmpl->nt_gc_interval);
492 if (tmpl->ce_mask & NEIGHTBL_ATTR_PARMS) {
493 struct rtnl_neightbl_parms *p = &tmpl->nt_parms;
497 goto nla_put_failure;
499 if (old->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX)
501 old->nt_parms.ntp_ifindex);
504 if (p->ntp_mask & NEIGHTBLPARM_ATTR_QUEUE_LEN)
505 NLA_PUT_U32(parms, NDTPA_QUEUE_LEN, p->ntp_queue_len);
507 if (p->ntp_mask & NEIGHTBLPARM_ATTR_APP_PROBES)
508 NLA_PUT_U32(parms, NDTPA_APP_PROBES, p->ntp_app_probes);
510 if (p->ntp_mask & NEIGHTBLPARM_ATTR_UCAST_PROBES)
512 p->ntp_ucast_probes);
514 if (p->ntp_mask & NEIGHTBLPARM_ATTR_MCAST_PROBES)
516 p->ntp_mcast_probes);
518 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_QLEN)
522 if (p->ntp_mask & NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME)
524 p->ntp_base_reachable_time);
526 if (p->ntp_mask & NEIGHTBLPARM_ATTR_RETRANS_TIME)
528 p->ntp_retrans_time);
530 if (p->ntp_mask & NEIGHTBLPARM_ATTR_GC_STALETIME)
532 p->ntp_gc_stale_time);
534 if (p->ntp_mask & NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME)
538 if (p->ntp_mask & NEIGHTBLPARM_ATTR_ANYCAST_DELAY)
540 p->ntp_anycast_delay);
542 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_DELAY)
546 if (p->ntp_mask & NEIGHTBLPARM_ATTR_LOCKTIME)
547 NLA_PUT_U64(parms, NDTPA_LOCKTIME, p->ntp_locktime);
550 goto nla_put_failure;
579 struct rtnl_neightbl *tmpl)
592 return wait_for_ack(sk);
602 void rtnl_neightbl_set_family(
struct rtnl_neightbl *ntbl,
int family)
604 ntbl->nt_family = family;
605 ntbl->ce_mask |= NEIGHTBL_ATTR_FAMILY;
608 void rtnl_neightbl_set_gc_interval(
struct rtnl_neightbl *ntbl, uint64_t ms)
610 ntbl->nt_gc_interval = ms;
611 ntbl->ce_mask |= NEIGHTBL_ATTR_GC_INTERVAL;
614 void rtnl_neightbl_set_gc_tresh1(
struct rtnl_neightbl *ntbl,
int thresh)
616 ntbl->nt_gc_thresh1 = thresh;
617 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH1;
620 void rtnl_neightbl_set_gc_tresh2(
struct rtnl_neightbl *ntbl,
int thresh)
622 ntbl->nt_gc_thresh2 = thresh;
623 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH2;
626 void rtnl_neightbl_set_gc_tresh3(
struct rtnl_neightbl *ntbl,
int thresh)
628 ntbl->nt_gc_thresh3 = thresh;
629 ntbl->ce_mask |= NEIGHTBL_ATTR_THRESH3;
632 void rtnl_neightbl_set_name(
struct rtnl_neightbl *ntbl,
const char *name)
634 strncpy(ntbl->nt_name, name,
sizeof(ntbl->nt_name) - 1);
635 ntbl->ce_mask |= NEIGHTBL_ATTR_NAME;
638 void rtnl_neightbl_set_dev(
struct rtnl_neightbl *ntbl,
int ifindex)
640 ntbl->nt_parms.ntp_ifindex = ifindex;
641 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_IFINDEX;
642 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
652 ntbl->nt_parms.ntp_queue_len = len;
653 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_QUEUE_LEN;
654 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
664 ntbl->nt_parms.ntp_proxy_qlen = len;
665 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_QLEN;
666 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
676 ntbl->nt_parms.ntp_app_probes = probes;
677 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_APP_PROBES;
678 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
688 ntbl->nt_parms.ntp_ucast_probes = probes;
689 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_UCAST_PROBES;
690 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
700 ntbl->nt_parms.ntp_mcast_probes = probes;
701 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_MCAST_PROBES;
702 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
713 ntbl->nt_parms.ntp_base_reachable_time = ms;
714 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME;
715 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
725 ntbl->nt_parms.ntp_retrans_time = ms;
726 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_RETRANS_TIME;
727 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
737 ntbl->nt_parms.ntp_gc_stale_time = ms;
738 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_GC_STALETIME;
739 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
749 ntbl->nt_parms.ntp_probe_delay = ms;
750 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME;
751 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
761 ntbl->nt_parms.ntp_anycast_delay = ms;
762 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_ANYCAST_DELAY;
763 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
773 ntbl->nt_parms.ntp_proxy_delay = ms;
774 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_DELAY;
775 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
785 ntbl->nt_parms.ntp_locktime = ms;
786 ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_LOCKTIME;
787 ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
792 static struct nl_object_ops neightbl_obj_ops = {
793 .oo_name =
"route/neightbl",
794 .oo_size =
sizeof(
struct rtnl_neightbl),
800 .oo_compare = neightbl_compare,
803 static struct nl_cache_ops rtnl_neightbl_ops = {
804 .co_name =
"route/neightbl",
805 .co_hdrsize =
sizeof(
struct rtgenmsg),
807 { RTM_NEWNEIGHTBL, NL_ACT_NEW,
"new" },
808 { RTM_SETNEIGHTBL, NL_ACT_SET,
"set" },
809 { RTM_GETNEIGHTBL, NL_ACT_GET,
"get" },
810 END_OF_MSGTYPES_LIST,
812 .co_protocol = NETLINK_ROUTE,
813 .co_request_update = neightbl_request_update,
814 .co_msg_parser = neightbl_msg_parser,
815 .co_obj_ops = &neightbl_obj_ops,
818 static void __init neightbl_init(
void)
823 static void __exit neightbl_exit(
void)
int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
Dump object briefly on one line.
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
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
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.
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
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.
int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
Unregister a set of cache operations.
Attribute validation policy.
struct nl_cache * nl_cache_mngt_require_safe(const char *name)
Return cache previously provided via nl_cache_mngt_provide()
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
#define NLA_PUT_U64(msg, attrtype, value)
Add 64 bit integer attribute to netlink message.
void rtnl_neightbl_set_locktime(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the locktime of a neighbour table to the specified value.
char * nl_msec2str(uint64_t msec, char *buf, size_t len)
Convert milliseconds to a character string.
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
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_app_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of application probes 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.
NUL terminated character string.
Dump all attributes but no statistics.
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, const struct nla_policy *policy)
Create attribute index based on nested attribute.
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
Send routing netlink request message.
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
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.
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 rtnl_neightbl_change(struct nl_sock *sk, struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
Change neighbour table attributes.
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 nlmsg_append(struct nl_msg *n, void *data, size_t len, int pad)
Append data to tail of a netlink message.
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
#define NLA_PUT_STRING(msg, attrtype, value)
Add string attribute to netlink message.
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_gc_stale_time(struct rtnl_neightbl *ntbl, uint64_t ms)
Set the gc stale time of a neighbour table to the specified value.
uint16_t type
Type of attribute or NLA_UNSPEC.
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 nl_msg * nlmsg_alloc_simple(int nlmsgtype, int flags)
Allocate a new netlink message.
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.
char * rtnl_link_i2name(struct nl_cache *cache, int ifindex, char *dst, size_t len)
Translate interface index to corresponding link name.
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_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
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_mcast_probes(struct rtnl_neightbl *ntbl, int probes)
Set the number of multicast probes of a neighbour table to the specified value.
Dump all attributes including statistics.
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.
size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
Copy string attribute payload to a buffer.