]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_fpm_netlink.c
Merge pull request #13414 from LabNConsulting/chopps/no-mgmtd-nowrite-on-off
[mirror_frr.git] / zebra / zebra_fpm_netlink.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
5adc2528
AS
2/*
3 * Code for encoding/decoding FPM messages that are in netlink format.
4 *
5 * Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
6 * Copyright (C) 2012 by Open Source Routing.
7 * Copyright (C) 2012 by Internet Systems Consortium, Inc. ("ISC")
5adc2528
AS
8 */
9
10#include <zebra.h>
11
ddfeb486
DL
12#ifdef HAVE_NETLINK
13
5adc2528
AS
14#include "log.h"
15#include "rib.h"
82f97584 16#include "vty.h"
e3be0432 17#include "prefix.h"
5adc2528 18
1fdc9eae 19#include "zebra/zserv.h"
b3f2b590 20#include "zebra/zebra_router.h"
85a75f1e 21#include "zebra/zebra_dplane.h"
1fdc9eae 22#include "zebra/zebra_ns.h"
23#include "zebra/zebra_vrf.h"
24#include "zebra/kernel_netlink.h"
25#include "zebra/rt_netlink.h"
fb018d25 26#include "nexthop.h"
5adc2528 27
1fdc9eae 28#include "zebra/zebra_fpm_private.h"
9d21b7c6 29#include "zebra/zebra_vxlan_private.h"
1b09e77e 30#include "zebra/interface.h"
5adc2528 31
5adc2528
AS
32/*
33 * af_addr_size
34 *
35 * The size of an address in a given address family.
36 */
d7c0a89a 37static size_t af_addr_size(uint8_t af)
5adc2528 38{
d62a17ae 39 switch (af) {
40
41 case AF_INET:
42 return 4;
d62a17ae 43 case AF_INET6:
44 return 16;
d62a17ae 45 default:
46 assert(0);
47 return 16;
48 }
5adc2528
AS
49}
50
9d21b7c6
AD
51/*
52 * We plan to use RTA_ENCAP_TYPE attribute for VxLAN encap as well.
53 * Currently, values 0 to 8 for this attribute are used by lwtunnel_encap_types
54 * So, we cannot use these values for VxLAN encap.
55 */
56enum fpm_nh_encap_type_t {
57 FPM_NH_ENCAP_NONE = 0,
58 FPM_NH_ENCAP_VXLAN = 100,
59 FPM_NH_ENCAP_MAX,
60};
61
62/*
63 * fpm_nh_encap_type_to_str
64 */
65static const char *fpm_nh_encap_type_to_str(enum fpm_nh_encap_type_t encap_type)
66{
67 switch (encap_type) {
68 case FPM_NH_ENCAP_NONE:
69 return "none";
70
71 case FPM_NH_ENCAP_VXLAN:
72 return "VxLAN";
73
74 case FPM_NH_ENCAP_MAX:
75 return "invalid";
76 }
77
78 return "invalid";
79}
80
81struct vxlan_encap_info_t {
82 vni_t vni;
83};
84
85enum vxlan_encap_info_type_t {
86 VXLAN_VNI = 0,
87};
88
89struct fpm_nh_encap_info_t {
90 enum fpm_nh_encap_type_t encap_type;
91 union {
92 struct vxlan_encap_info_t vxlan_encap;
93 };
94};
95
5adc2528 96/*
7cf19069 97 * netlink_nh_info
5adc2528
AS
98 *
99 * Holds information about a single nexthop for netlink. These info
100 * structures are transient and may contain pointers into rib
101 * data structures for convenience.
102 */
7cf19069 103struct netlink_nh_info {
eca3256d 104 /* Weight of the nexthop ( for unequal cost ECMP ) */
105 uint8_t weight;
d62a17ae 106 uint32_t if_index;
107 union g_addr *gateway;
108
109 /*
110 * Information from the struct nexthop from which this nh was
111 * derived. For debug purposes only.
112 */
113 int recursive;
114 enum nexthop_types_t type;
9d21b7c6 115 struct fpm_nh_encap_info_t encap_info;
7cf19069 116};
5adc2528
AS
117
118/*
67ceb408 119 * netlink_route_info
5adc2528
AS
120 *
121 * A structure for holding information for a netlink route message.
122 */
67ceb408 123struct netlink_route_info {
869a5f71 124 uint32_t nlmsg_pid;
d62a17ae 125 uint16_t nlmsg_type;
d7c0a89a 126 uint8_t rtm_type;
d62a17ae 127 uint32_t rtm_table;
d7c0a89a
QY
128 uint8_t rtm_protocol;
129 uint8_t af;
d62a17ae 130 struct prefix *prefix;
131 uint32_t *metric;
132 unsigned int num_nhs;
133
134 /*
135 * Nexthop structures
136 */
7cf19069 137 struct netlink_nh_info nhs[MULTIPATH_NUM];
d62a17ae 138 union g_addr *pref_src;
67ceb408 139};
5adc2528
AS
140
141/*
142 * netlink_route_info_add_nh
143 *
144 * Add information about the given nexthop to the given route info
145 * structure.
146 *
2951a7a4 147 * Returns true if a nexthop was added, false otherwise.
5adc2528 148 */
67ceb408 149static int netlink_route_info_add_nh(struct netlink_route_info *ri,
9d21b7c6
AD
150 struct nexthop *nexthop,
151 struct route_entry *re)
5adc2528 152{
7cf19069 153 struct netlink_nh_info nhi;
d62a17ae 154 union g_addr *src;
1b09e77e
AD
155 struct zebra_vrf *zvrf = NULL;
156 struct interface *ifp = NULL, *link_if = NULL;
157 struct zebra_if *zif = NULL;
158 vni_t vni = 0;
d62a17ae 159
160 memset(&nhi, 0, sizeof(nhi));
161 src = NULL;
162
7e3a1ec7 163 if (ri->num_nhs >= (int)array_size(ri->nhs))
d62a17ae 164 return 0;
165
166 nhi.recursive = nexthop->rparent ? 1 : 0;
167 nhi.type = nexthop->type;
168 nhi.if_index = nexthop->ifindex;
eca3256d 169 nhi.weight = nexthop->weight;
d62a17ae 170
171 if (nexthop->type == NEXTHOP_TYPE_IPV4
172 || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
173 nhi.gateway = &nexthop->gate;
975a328e 174 if (nexthop->src.ipv4.s_addr != INADDR_ANY)
d62a17ae 175 src = &nexthop->src;
176 }
177
178 if (nexthop->type == NEXTHOP_TYPE_IPV6
179 || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
316d2d52
NK
180 /* Special handling for IPv4 route with IPv6 Link Local next hop
181 */
182 if (ri->af == AF_INET)
183 nhi.gateway = &ipv4ll_gateway;
184 else
185 nhi.gateway = &nexthop->gate;
d62a17ae 186 }
187
188 if (nexthop->type == NEXTHOP_TYPE_IFINDEX) {
975a328e 189 if (nexthop->src.ipv4.s_addr != INADDR_ANY)
d62a17ae 190 src = &nexthop->src;
191 }
192
193 if (!nhi.gateway && nhi.if_index == 0)
194 return 0;
195
5609e70f 196 if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_EVPN)) {
9d21b7c6
AD
197 nhi.encap_info.encap_type = FPM_NH_ENCAP_VXLAN;
198
1b09e77e
AD
199 /* Extract VNI id for the nexthop SVI interface */
200 zvrf = zebra_vrf_lookup_by_id(nexthop->vrf_id);
201 if (zvrf) {
202 ifp = if_lookup_by_index_per_ns(zvrf->zns,
203 nexthop->ifindex);
204 if (ifp) {
205 zif = (struct zebra_if *)ifp->info;
206 if (zif) {
207 if (IS_ZEBRA_IF_BRIDGE(ifp))
208 link_if = ifp;
209 else if (IS_ZEBRA_IF_VLAN(ifp))
210 link_if =
211 if_lookup_by_index_per_ns(
212 zvrf->zns,
213 zif->link_ifindex);
214 if (link_if)
215 vni = vni_id_from_svi(ifp,
216 link_if);
217 }
218 }
9d21b7c6 219 }
1b09e77e
AD
220
221 nhi.encap_info.vxlan_encap.vni = vni;
9d21b7c6
AD
222 }
223
d62a17ae 224 /*
225 * We have a valid nhi. Copy the structure over to the route_info.
226 */
227 ri->nhs[ri->num_nhs] = nhi;
228 ri->num_nhs++;
229
230 if (src && !ri->pref_src)
231 ri->pref_src = src;
232
233 return 1;
5adc2528
AS
234}
235
236/*
237 * netlink_proto_from_route_type
238 */
d7c0a89a 239static uint8_t netlink_proto_from_route_type(int type)
5adc2528 240{
4a563f27 241 return zebra2proto(type);
5adc2528
AS
242}
243
244/*
245 * netlink_route_info_fill
246 *
247 * Fill out the route information object from the given route.
248 *
2951a7a4 249 * Returns true on success and false on failure.
5adc2528 250 */
67ceb408 251static int netlink_route_info_fill(struct netlink_route_info *ri, int cmd,
d62a17ae 252 rib_dest_t *dest, struct route_entry *re)
5adc2528 253{
d62a17ae 254 struct nexthop *nexthop;
d62a17ae 255
256 memset(ri, 0, sizeof(*ri));
257
258 ri->prefix = rib_dest_prefix(dest);
259 ri->af = rib_dest_af(dest);
260
0eaa6523 261 ri->nlmsg_pid = pid;
869a5f71 262
d62a17ae 263 ri->nlmsg_type = cmd;
d62a17ae 264 ri->rtm_protocol = RTPROT_UNSPEC;
265
266 /*
267 * An RTM_DELROUTE need not be accompanied by any nexthops,
268 * particularly in our communication with the FPM.
269 */
270 if (cmd == RTM_DELROUTE && !re)
271 return 1;
272
273 if (!re) {
5e81f5dd 274 zfpm_debug("%s: Expected non-NULL re pointer", __func__);
d62a17ae 275 return 0;
276 }
277
0eaa6523
DS
278 ri->rtm_table = re->table;
279
d62a17ae 280 ri->rtm_protocol = netlink_proto_from_route_type(re->type);
a8309422 281 ri->rtm_type = RTN_UNICAST;
d62a17ae 282 ri->metric = &re->metric;
283
c415d895 284 for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {
b3f2b590 285 if (ri->num_nhs >= zrouter.multipath_num)
d62a17ae 286 break;
287
288 if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
289 continue;
290
a8309422
DL
291 if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE) {
292 switch (nexthop->bh_type) {
293 case BLACKHOLE_ADMINPROHIB:
294 ri->rtm_type = RTN_PROHIBIT;
295 break;
296 case BLACKHOLE_REJECT:
297 ri->rtm_type = RTN_UNREACHABLE;
298 break;
299 case BLACKHOLE_NULL:
a98701f0 300 case BLACKHOLE_UNSPEC:
a8309422
DL
301 ri->rtm_type = RTN_BLACKHOLE;
302 break;
303 }
a8309422
DL
304 }
305
d62a17ae 306 if ((cmd == RTM_NEWROUTE
307 && CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
308 || (cmd == RTM_DELROUTE
677c1dd5 309 && CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED))) {
9d21b7c6 310 netlink_route_info_add_nh(ri, nexthop, re);
d62a17ae 311 }
312 }
313
94f77863
DE
314 if (ri->num_nhs == 0) {
315 switch (ri->rtm_type) {
316 case RTN_PROHIBIT:
317 case RTN_UNREACHABLE:
318 case RTN_BLACKHOLE:
319 break;
320 default:
321 /* If there is no useful nexthop then return. */
322 zfpm_debug(
323 "netlink_encode_route(): No useful nexthop.");
324 return 0;
325 }
d62a17ae 326 }
327
328 return 1;
5adc2528
AS
329}
330
331/*
332 * netlink_route_info_encode
333 *
334 * Returns the number of bytes written to the buffer. 0 or a negative
335 * value indicates an error.
336 */
67ceb408
DS
337static int netlink_route_info_encode(struct netlink_route_info *ri,
338 char *in_buf, size_t in_buf_len)
5adc2528 339{
d62a17ae 340 size_t bytelen;
341 unsigned int nexthop_num = 0;
342 size_t buf_offset;
7cf19069 343 struct netlink_nh_info *nhi;
9d21b7c6 344 enum fpm_nh_encap_type_t encap;
312a6bee
JU
345 struct rtattr *nest, *inner_nest;
346 struct rtnexthop *rtnh;
9d21b7c6 347 struct vxlan_encap_info_t *vxlan;
92d6f769 348 struct in6_addr ipv6;
5adc2528 349
d62a17ae 350 struct {
351 struct nlmsghdr n;
352 struct rtmsg r;
353 char buf[1];
354 } * req;
5adc2528 355
d62a17ae 356 req = (void *)in_buf;
5adc2528 357
d62a17ae 358 buf_offset = ((char *)req->buf) - ((char *)req);
5adc2528 359
d62a17ae 360 if (in_buf_len < buf_offset) {
361 assert(0);
362 return 0;
363 }
5adc2528 364
d62a17ae 365 memset(req, 0, buf_offset);
5adc2528 366
d62a17ae 367 bytelen = af_addr_size(ri->af);
5adc2528 368
d62a17ae 369 req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
370 req->n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST;
869a5f71 371 req->n.nlmsg_pid = ri->nlmsg_pid;
d62a17ae 372 req->n.nlmsg_type = ri->nlmsg_type;
373 req->r.rtm_family = ri->af;
6dfcd754
AD
374
375 /*
f5267398 376 * rtm_table field is a uchar field which can accommodate table_id less
6dfcd754
AD
377 * than 256.
378 * To support table id greater than 255, if the table_id is greater than
379 * 255, set rtm_table to RT_TABLE_UNSPEC and add RTA_TABLE attribute
380 * with 32 bit value as the table_id.
381 */
382 if (ri->rtm_table < 256)
383 req->r.rtm_table = ri->rtm_table;
384 else {
385 req->r.rtm_table = RT_TABLE_UNSPEC;
312a6bee 386 nl_attr_put32(&req->n, in_buf_len, RTA_TABLE, ri->rtm_table);
6dfcd754
AD
387 }
388
d62a17ae 389 req->r.rtm_dst_len = ri->prefix->prefixlen;
390 req->r.rtm_protocol = ri->rtm_protocol;
391 req->r.rtm_scope = RT_SCOPE_UNIVERSE;
5adc2528 392
312a6bee
JU
393 nl_attr_put(&req->n, in_buf_len, RTA_DST, &ri->prefix->u.prefix,
394 bytelen);
5adc2528 395
d62a17ae 396 req->r.rtm_type = ri->rtm_type;
5adc2528 397
d62a17ae 398 /* Metric. */
399 if (ri->metric)
312a6bee 400 nl_attr_put32(&req->n, in_buf_len, RTA_PRIORITY, *ri->metric);
5adc2528 401
d62a17ae 402 if (ri->num_nhs == 0)
403 goto done;
5adc2528 404
d62a17ae 405 if (ri->num_nhs == 1) {
406 nhi = &ri->nhs[0];
5adc2528 407
d62a17ae 408 if (nhi->gateway) {
92d6f769
K
409 if (nhi->type == NEXTHOP_TYPE_IPV4_IFINDEX
410 && ri->af == AF_INET6) {
411 ipv4_to_ipv4_mapped_ipv6(&ipv6,
412 nhi->gateway->ipv4);
413 nl_attr_put(&req->n, in_buf_len, RTA_GATEWAY,
414 &ipv6, bytelen);
415 } else
416 nl_attr_put(&req->n, in_buf_len, RTA_GATEWAY,
417 nhi->gateway, bytelen);
d62a17ae 418 }
5adc2528 419
d62a17ae 420 if (nhi->if_index) {
312a6bee
JU
421 nl_attr_put32(&req->n, in_buf_len, RTA_OIF,
422 nhi->if_index);
d62a17ae 423 }
5adc2528 424
9d21b7c6 425 encap = nhi->encap_info.encap_type;
58c3cdb9
DS
426 switch (encap) {
427 case FPM_NH_ENCAP_NONE:
428 case FPM_NH_ENCAP_MAX:
429 break;
430 case FPM_NH_ENCAP_VXLAN:
312a6bee
JU
431 nl_attr_put16(&req->n, in_buf_len, RTA_ENCAP_TYPE,
432 encap);
58c3cdb9 433 vxlan = &nhi->encap_info.vxlan_encap;
312a6bee
JU
434 nest = nl_attr_nest(&req->n, in_buf_len, RTA_ENCAP);
435 nl_attr_put32(&req->n, in_buf_len, VXLAN_VNI,
436 vxlan->vni);
437 nl_attr_nest_end(&req->n, nest);
58c3cdb9 438 break;
9d21b7c6
AD
439 }
440
d62a17ae 441 goto done;
5adc2528
AS
442 }
443
d62a17ae 444 /*
445 * Multipath case.
446 */
312a6bee 447 nest = nl_attr_nest(&req->n, in_buf_len, RTA_MULTIPATH);
d62a17ae 448
449 for (nexthop_num = 0; nexthop_num < ri->num_nhs; nexthop_num++) {
312a6bee 450 rtnh = nl_attr_rtnh(&req->n, in_buf_len);
d62a17ae 451 nhi = &ri->nhs[nexthop_num];
452
312a6bee
JU
453 if (nhi->gateway)
454 nl_attr_put(&req->n, in_buf_len, RTA_GATEWAY,
455 nhi->gateway, bytelen);
d62a17ae 456
457 if (nhi->if_index) {
458 rtnh->rtnh_ifindex = nhi->if_index;
459 }
460
eca3256d 461 rtnh->rtnh_hops = nhi->weight;
462
9d21b7c6 463 encap = nhi->encap_info.encap_type;
58c3cdb9
DS
464 switch (encap) {
465 case FPM_NH_ENCAP_NONE:
466 case FPM_NH_ENCAP_MAX:
467 break;
468 case FPM_NH_ENCAP_VXLAN:
312a6bee
JU
469 nl_attr_put16(&req->n, in_buf_len, RTA_ENCAP_TYPE,
470 encap);
58c3cdb9 471 vxlan = &nhi->encap_info.vxlan_encap;
312a6bee
JU
472 inner_nest =
473 nl_attr_nest(&req->n, in_buf_len, RTA_ENCAP);
474 nl_attr_put32(&req->n, in_buf_len, VXLAN_VNI,
475 vxlan->vni);
476 nl_attr_nest_end(&req->n, inner_nest);
58c3cdb9 477 break;
9d21b7c6
AD
478 }
479
312a6bee 480 nl_attr_rtnh_end(&req->n, rtnh);
5adc2528
AS
481 }
482
312a6bee
JU
483 nl_attr_nest_end(&req->n, nest);
484 assert(nest->rta_len > RTA_LENGTH(0));
5adc2528
AS
485
486done:
487
d62a17ae 488 if (ri->pref_src) {
18b7958e 489 nl_attr_put(&req->n, in_buf_len, RTA_PREFSRC, ri->pref_src,
312a6bee 490 bytelen);
d62a17ae 491 }
5adc2528 492
d62a17ae 493 assert(req->n.nlmsg_len < in_buf_len);
494 return req->n.nlmsg_len;
5adc2528
AS
495}
496
497/*
498 * zfpm_log_route_info
499 *
500 * Helper function to log the information in a route_info structure.
501 */
67ceb408
DS
502static void zfpm_log_route_info(struct netlink_route_info *ri,
503 const char *label)
5adc2528 504{
7cf19069 505 struct netlink_nh_info *nhi;
d62a17ae 506 unsigned int i;
9bcef951 507 char buf[PREFIX_STRLEN];
d62a17ae 508
5e9f9adb
DL
509 zfpm_debug("%s : %s %pFX, Proto: %s, Metric: %u", label,
510 nl_msg_type_to_str(ri->nlmsg_type), ri->prefix,
d62a17ae 511 nl_rtproto_to_str(ri->rtm_protocol),
512 ri->metric ? *ri->metric : 0);
513
514 for (i = 0; i < ri->num_nhs; i++) {
515 nhi = &ri->nhs[i];
9bcef951 516
278749ca 517 if (nhi->gateway) {
518 if (ri->af == AF_INET)
519 inet_ntop(AF_INET, nhi->gateway, buf,
520 sizeof(buf));
521 else
522 inet_ntop(AF_INET6, nhi->gateway, buf,
523 sizeof(buf));
524 } else
525 strlcpy(buf, "none", sizeof(buf));
9bcef951 526
9d21b7c6 527 zfpm_debug(" Intf: %u, Gateway: %s, Recursive: %s, Type: %s, Encap type: %s",
9bcef951 528 nhi->if_index, buf, nhi->recursive ? "yes" : "no",
9d21b7c6
AD
529 nexthop_type_to_str(nhi->type),
530 fpm_nh_encap_type_to_str(nhi->encap_info.encap_type)
531 );
d62a17ae 532 }
5adc2528
AS
533}
534
535/*
536 * zfpm_netlink_encode_route
537 *
538 * Create a netlink message corresponding to the given route in the
539 * given buffer space.
540 *
541 * Returns the number of bytes written to the buffer. 0 or a negative
542 * value indicates an error.
543 */
d62a17ae 544int zfpm_netlink_encode_route(int cmd, rib_dest_t *dest, struct route_entry *re,
545 char *in_buf, size_t in_buf_len)
5adc2528 546{
67ceb408 547 struct netlink_route_info ri_space, *ri;
5adc2528 548
d62a17ae 549 ri = &ri_space;
5adc2528 550
d62a17ae 551 if (!netlink_route_info_fill(ri, cmd, dest, re))
552 return 0;
5adc2528 553
15569c58 554 zfpm_log_route_info(ri, __func__);
5adc2528 555
d62a17ae 556 return netlink_route_info_encode(ri, in_buf, in_buf_len);
5adc2528 557}
ddfeb486 558
9da60d0a
AD
559/*
560 * zfpm_netlink_encode_mac
561 *
562 * Create a netlink message corresponding to the given MAC.
563 *
564 * Returns the number of bytes written to the buffer. 0 or a negative
565 * value indicates an error.
566 */
567int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
568 size_t in_buf_len)
569{
9da60d0a
AD
570 size_t buf_offset;
571
c5431822 572 struct macmsg {
9da60d0a
AD
573 struct nlmsghdr hdr;
574 struct ndmsg ndm;
575 char buf[0];
576 } *req;
577 req = (void *)in_buf;
578
c5431822 579 buf_offset = offsetof(struct macmsg, buf);
9da60d0a
AD
580 if (in_buf_len < buf_offset)
581 return 0;
582 memset(req, 0, buf_offset);
583
584 /* Construct nlmsg header */
585 req->hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg));
586 req->hdr.nlmsg_type = CHECK_FLAG(mac->fpm_flags, ZEBRA_MAC_DELETE_FPM) ?
587 RTM_DELNEIGH : RTM_NEWNEIGH;
588 req->hdr.nlmsg_flags = NLM_F_REQUEST;
589 if (req->hdr.nlmsg_type == RTM_NEWNEIGH)
590 req->hdr.nlmsg_flags |= (NLM_F_CREATE | NLM_F_REPLACE);
591
592 /* Construct ndmsg */
593 req->ndm.ndm_family = AF_BRIDGE;
594 req->ndm.ndm_ifindex = mac->vxlan_if;
595
596 req->ndm.ndm_state = NUD_REACHABLE;
597 req->ndm.ndm_flags |= NTF_SELF | NTF_MASTER;
598 if (CHECK_FLAG(mac->zebra_flags,
599 (ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW)))
600 req->ndm.ndm_state |= NUD_NOARP;
601 else
602 req->ndm.ndm_flags |= NTF_EXT_LEARNED;
603
604 /* Add attributes */
312a6bee
JU
605 nl_attr_put(&req->hdr, in_buf_len, NDA_LLADDR, &mac->macaddr, 6);
606 nl_attr_put(&req->hdr, in_buf_len, NDA_DST, &mac->r_vtep_ip, 4);
607 nl_attr_put32(&req->hdr, in_buf_len, NDA_MASTER, mac->svi_if);
608 nl_attr_put32(&req->hdr, in_buf_len, NDA_VNI, mac->vni);
9da60d0a
AD
609
610 assert(req->hdr.nlmsg_len < in_buf_len);
611
5e9f9adb 612 zfpm_debug("Tx %s family %s ifindex %u MAC %pEA DEST %pI4",
9da60d0a
AD
613 nl_msg_type_to_str(req->hdr.nlmsg_type),
614 nl_family_to_str(req->ndm.ndm_family), req->ndm.ndm_ifindex,
5e9f9adb 615 &mac->macaddr, &mac->r_vtep_ip);
9da60d0a
AD
616
617 return req->hdr.nlmsg_len;
618}
619
ddfeb486 620#endif /* HAVE_NETLINK */