• Home
  • Raw
  • Download

Lines Matching full:link

24 The link configuration interface is part of the +NETLINK_ROUTE+ protocol
30 - View and modify per link network configuration settings (e.g.
33 .Naming Convention (network device, link, interface)
44 This section describes the protocol semantics of the netlink based link
51 | Reply to +RTM_GETLINK+ request or notification of link added or updated
53 | Notification of link deleted or disappeared
54 | +RTM_GETLINK+ | Retrieve link configuration and statistics |
55 | +RTM_SETLINK+ | Modify link configuration |
58 See link:core.html#core_msg_types[Netlink Library - Message Types] for more
61 ==== Link Message Format
63 All netlink link messages share a common header (+struct ifinfomsg+) which
66 image:ifinfomsg.png["Link Message Header"]
77 Link Layer Type (16bit)::
78 Currently only used in kernel->user messages to report the link layer type
79 of a link. The value corresponds to the +ARPHRD_*+ defines found in
83 Link Index (32bit)::
88 state of the link flags. In user->kernel messages this field is used to
95 to this field when present in link notifications, see TODO.
98 All link message types may carry netlink attributes. They are defined in the
101 ==== Link Message Types
105 Lookup link by 1. interface index or 2. link name (+IFLA_IFNAME+) and return
106 a single +RTM_NEWLINK+ message containing the link configuration and statistics
107 or a netlink error message if no such link was found.
124 * +EINVAL+ if neither interface nor link name are set
125 * +ENODEV+ if no link was found
130 Creates a new or updates an existing link. Only virtual links may be created
135 - +NLM_F_CREATE+ Create link if it does not exist
136 - +NLM_F_EXCL+ Return +EEXIST+ if link already exists
143 - +EOPNOTSUPP+ if the link does not support modification of parameters
144 - +EEXIST+ if +NLM_F_EXCL+ was set and the link exists alraedy
145 - +ENODEV+ if the link does not exist and +NLM_F_CREATE+ is not set
150 the configuration and statistics of a link. If multiple links need to
154 multicast group +RTNLGRP_LINK+ to inform about various link events. It is
155 therefore recommended to always use a separate link socket for link
162 Lookup link by 1. interface index or 2. link name (+IFLA_IFNAME+) and delete
163 the virtual link.
167 * +EINVAL+ if neither interface nor link name are set
168 * +ENODEV+ if no link was found
169 * +ENOTSUPP+ if the operation is not supported (not a virtual link)
183 To retrieve the list of links in the kernel, allocate a new link cache
186 from the kernel and feed the returned +RTM_NEWLINK+ to the internal link
191 #include <netlink/route/link.h>
196 The cache will contain link objects (+struct rtnl_link+, see <<link_object>>)
202 index and by link name:
206 #include <netlink/route/link.h>
212 .Example: Link Cache
217 struct rtnl_link *link;
222 if (!(link = rtnl_link_get_by_name(cache, "eth1")))
223 /* link does not exist */
225 /* do something with link */
227 rtnl_link_put(link);
232 ==== Lookup Single Link (Direct Lookup)
234 If only a single link is of interest, the link can be looked up directly
235 without the use of a link cache using the function +rtnl_link_get_kernel()+.
239 #include <netlink/route/link.h>
246 return. If the link exists, the link is returned as link object
249 .Example: Direct link lookup
252 struct rtnl_link *link;
254 if (rtnl_link_get_kernel(sock, 0, "eth1", &link) < 0)
257 /* do something with link */
259 rtnl_link_put(link);
268 ==== Translating interface index to link name
270 Applications which require to translate interface index to a link name or
272 a filled link cache to work with.
282 Several types of virtual link can be added on the fly using the function
287 #include <netlink/route/link.h>
289 int rtnl_link_add(struct nl_sock *sk, struct rtnl_link *link, int flags);
295 using the function +rtnl_link_delete()+. The link passed on to the function
296 can be a link from a link cache or it can be construct with the minimal
297 attributes needed to identify the link.
301 #include <netlink/route/link.h>
303 int rtnl_link_delete(struct nl_sock *sk, const struct rtnl_link *link);
309 .Example: Delete link by name
312 struct rtnl_link *link;
314 if (!(link = rtnl_link_alloc()))
317 rtnl_link_set_name(link, "my_vlan");
319 if (rtnl_link_delete(sock, link) < 0)
322 rtnl_link_put(link);
326 === Link Object
328 A link is represented by the structure +struct rtnl_link+. Instances may be
329 created with the function +rtnl_link_alloc()+ or via a link cache (see
334 #include <netlink/route/link.h>
337 void rtnl_link_put(struct rtnl_link *link);
342 The name serves as unique, human readable description of the link. By
346 Kernels >= 2.6.11 support identification by link name.
350 #include <netlink/route/link.h>
352 void rtnl_link_set_name(struct rtnl_link *link, const char *name);
353 char *rtnl_link_get_name(struct rtnl_link *link);
356 *Accepted link name format:* +[^ /]*+ (maximum length: 15 characters)
360 The interface index is an integer uniquely identifying a link. If present
361 in any link message, it will be used to identify an existing link.
365 #include <netlink/route/link.h>
367 void rtnl_link_set_ifindex(struct rtnl_link *link, int ifindex);
368 int rtnl_link_get_ifindex(struct rtnl_link *link);
373 Each link can be assigned a numeric group identifier to group a bunch of links
374 together and apply a set of changes to a group instead of just a single link.
379 #include <netlink/route/link.h>
381 void rtnl_link_set_group(struct rtnl_link *link, uint32_t group);
382 uint32_t rtnl_link_get_group(struct rtnl_link *link);
386 ==== Link Layer Address
387 The link layer address (e.g. MAC address).
391 #include <netlink/route/link.h>
393 void rtnl_link_set_addr(struct rtnl_link *link, struct nl_addr *addr);
394 struct nl_addr *rtnl_link_get_addr(struct rtnl_link *link);
399 The link layer broadcast address
403 #include <netlink/route/link.h>
405 void rtnl_link_set_broadcast(struct rtnl_link *link, struct nl_addr *addr);
406 struct nl_addr *rtnl_link_get_broadcast(struct rtnl_link *link);
417 #include <netlink/route/link.h>
419 void rtnl_link_set_mtu(struct rtnl_link *link, unsigned int mtu);
420 unsigned int rtnl_link_get_mtu(struct rtnl_link *link);
425 The flags of a link enable or disable various link features or inform about
426 the state of the link.
430 #include <netlink/route/link.h>
432 void rtnl_link_set_flags(struct rtnl_link *link, unsigned int flags);
433 void rtnl_link_unset_flags(struct rtnl_link *link, unsigned int flags);
434 unsigned int rtnl_link_get_flags(struct rtnl_link *link);
439 IFF_UP:: Link is up (administratively)
440 IFF_RUNNING:: Link is up and carrier is OK (RFC2863 OPER_UP)
441 IFF_LOWER_UP:: Link layer is operational
443 IFF_BROADCAST:: Link supports broadcasting
444 IFF_MULTICAST:: Link supports multicasting
445 IFF_ALLMULTI:: Link supports multicast routing
447 IFF_LOOPBACK:: Link loopback network
448 IFF_POINTOPOINT:: Point-to-point link
452 IFF_SLAVE:: Slave to a master link
454 IFF_AUTOMEDIA:: Link selects port automatically (only used by ARM ethernet)
459 To translate a link flag to a link flag name or vice versa:
463 #include <netlink/route/link.h>
474 packets but the unit may be specific to the link type.
478 #include <netlink/route/link.h>
480 void rtnl_link_set_txqlen(struct rtnl_link *link, unsigned int txqlen);
481 unsigned int rtnl_link_get_txqlen(struct rtnl_link *link);
487 on the link status. Traditionally the link state has been described using
488 the link flags +IFF_UP, IFF_RUNNING, IFF_LOWER_UP+, and +IFF_DORMANT+ which
489 was no longer sufficient for some link types.
493 #include <netlink/route/link.h>
495 void rtnl_link_set_operstate(struct rtnl_link *link, uint8_t state);
496 uint8_t rtnl_link_get_operstate(struct rtnl_link *link);
502 IF_OPER_NOTPRESENT:: Link not present
503 IF_OPER_DOWN:: Link down
507 IF_OPER_UP:: Link up
513 #include <netlink/route/link.h>
521 Currently known link modes are:
525 IF_LINK_MODE_DEFAULT:: Default link mode
530 #include <netlink/route/link.h>
532 void rtnl_link_set_linkmode(struct rtnl_link *link, uint8_t mode);
533 uint8_t rtnl_link_get_linkmode(struct rtnl_link *link);
536 Translation of link mode to string and vice versa:
546 Alternative name for the link, primarly used for SNMP IfAlias.
550 #include <netlink/route/link.h>
552 const char *rtnl_link_get_ifalias(struct rtnl_link *link);
553 void rtnl_link_set_ifalias(struct rtnl_link *link, const char *alias);
563 #include <netlink/route/link.h>
566 void rtnl_link_set_arptype(struct rtnl_link *link, unsigned int arptype);
567 unsigned int rtnl_link_get_arptype(struct rtnl_link *link);
582 The name of the queueing discipline used by the link is of informational
585 link objects to be used for comparison.
587 For more information on how to modify the qdisc of a link, see section
592 #include <netlink/route/link.h>
594 void rtnl_link_set_qdisc(struct rtnl_link *link, const char *name);
595 char *rtnl_link_get_qdisc(struct rtnl_link *link);
600 The number of subsystem currently depending on the link being promiscuous mode.
601 A value of 0 indicates that the link is not in promiscuous mode. It is a
603 function is provided solely for the purpose of creating link objects to be
608 #include <netlink/route/link.h>
610 void rtnl_link_set_promiscuity(struct rtnl_link *link, uint32_t count);
611 uint32_t rtnl_link_get_promiscuity(struct rtnl_link *link);
616 The number of RX/TX queues the link provides. The attribute is writable but
621 #include <netlink/route/link.h>
623 void rtnl_link_set_num_tx_queues(struct rtnl_link *link, uint32_t nqueues);
624 uint32_t rtnl_link_get_num_tx_queues(struct rtnl_link *link);
626 void rtnl_link_set_num_rx_queues(struct rtnl_link *link, uint32_t nqueues);
627 uint32_t rtnl_link_get_num_rx_queues(struct rtnl_link *link);
641 .Example: Add bonding link
644 #include <netlink/route/link.h>
646 struct rtnl_link *link;
648 link = rtnl_link_bond_alloc();
649 rtnl_link_set_name(link, "my_bond");
652 if (rtnl_link_add(sk, link, NLM_F_CREATE) < 0)
655 rtnl_link_put(link);
688 struct rtnl_link *link;
695 /* allocate new link object of type vlan */
696 link = rtnl_link_vlan_alloc();
699 rtnl_link_set_link(link, master_index);
701 rtnl_link_vlan_set_id(link, 10);
703 if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
706 rtnl_link_put(link);
738 struct rtnl_link *link;
746 /* allocate new link object of type macvlan */
747 link = rtnl_link_macvlan_alloc();
750 rtnl_link_set_link(link, master_index);
754 rtnl_link_set_addr(link, addr);
758 rtnl_link_macvlan_set_mode(link, rtnl_link_macvlan_str2mode("bridge"));
760 if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
763 rtnl_link_put(link);
833 struct rtnl_link *link;
836 /* allocate new link object of type vxlan */
837 link = rtnl_link_vxlan_alloc();
840 rtnl_link_set_name(link, "vxlan128");
843 if ((err = rtnl_link_vxlan_set_id(link, 128)) < 0)
850 if ((err = rtnl_link_set_group(link, addr)) < 0)
855 if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
858 rtnl_link_put(link);
869 extern int rtnl_link_ipip_set_link(struct rtnl_link *link, uint32_t index);
870 extern uint32_t rtnl_link_ipip_get_link(struct rtnl_link *link);
872 extern int rtnl_link_ipip_set_local(struct rtnl_link *link, uint32_t addr);
873 extern uint32_t rtnl_link_ipip_get_local(struct rtnl_link *link);
875 extern int rtnl_link_ipip_set_remote(struct rtnl_link *link, uint32_t addr);
876 extern uint32_t rtnl_link_ipip_get_remote(struct rtnl_link *link);
878 extern int rtnl_link_ipip_set_ttl(struct rtnl_link *link, uint8_t ttl);
879 extern uint8_t rtnl_link_ipip_get_ttl(struct rtnl_link *link);
881 extern int rtnl_link_ipip_set_tos(struct rtnl_link *link, uint8_t tos);
882 extern uint8_t rtnl_link_ipip_get_tos(struct rtnl_link *link);
884 extern int rtnl_link_ipip_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc);
885 extern uint8_t rtnl_link_ipip_get_pmtudisc(struct rtnl_link *link);
892 struct rtnl_link *link
895 /* allocate new link object of type vxlan */
896 if(!(link = rtnl_link_ipip_alloc()))
900 if ((err = rtnl_link_set_name(link, "ipip-tun")) < 0)
903 /* set link index */
904 if ((err = rtnl_link_ipip_set_link(link, if_index)) < 0)
909 if ((err = rtnl_link_ipip_set_local(link, addr.s_addr)) < 0)
914 if ((err = rtnl_link_ipip_set_remote(link, addr.s_addr)) < 0)
918 if ((err = rtnl_link_ipip_set_ttl(link, 64)) < 0)
921 if((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
924 rtnl_link_put(link);
935 extern int rtnl_link_ipgre_set_link(struct rtnl_link *link, uint32_t index);
936 extern uint32_t rtnl_link_ipgre_get_link(struct rtnl_link *link);
938 extern int rtnl_link_ipgre_set_iflags(struct rtnl_link *link, uint16_t iflags);
939 extern uint16_t rtnl_link_get_iflags(struct rtnl_link *link);
941 extern int rtnl_link_ipgre_set_oflags(struct rtnl_link *link, uint16_t oflags);
942 extern uint16_t rtnl_link_get_oflags(struct rtnl_link *link);
944 extern int rtnl_link_ipgre_set_ikey(struct rtnl_link *link, uint32_t ikey);
945 extern uint32_t rtnl_link_get_ikey(struct rtnl_link *link);
947 extern int rtnl_link_ipgre_set_okey(struct rtnl_link *link, uint32_t okey);
948 extern uint32_t rtnl_link_get_okey(struct rtnl_link *link)
950 extern int rtnl_link_ipgre_set_local(struct rtnl_link *link, uint32_t addr);
951 extern uint32_t rtnl_link_ipgre_get_local(struct rtnl_link *link);
953 extern int rtnl_link_ipgre_set_remote(struct rtnl_link *link, uint32_t addr);
954 extern uint32_t rtnl_link_ipgre_get_remote(struct rtnl_link *link);
956 extern int rtnl_link_ipgre_set_ttl(struct rtnl_link *link, uint8_t ttl);
957 extern uint8_t rtnl_link_ipgre_get_ttl(struct rtnl_link *link);
959 extern int rtnl_link_ipgre_set_tos(struct rtnl_link *link, uint8_t tos);
960 extern uint8_t rtnl_link_ipgre_get_tos(struct rtnl_link *link);
962 extern int rtnl_link_ipgre_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc);
963 extern uint8_t rtnl_link_ipgre_get_pmtudisc(struct rtnl_link *link);
970 struct rtnl_link *link
973 /* allocate new link object of type vxlan */
974 if(!(link = rtnl_link_ipgre_alloc()))
978 if ((err = rtnl_link_set_name(link, "ipgre-tun")) < 0)
981 /* set link index */
982 if ((err = rtnl_link_ipgre_set_link(link, if_index)) < 0)
987 if ((err = rtnl_link_ipgre_set_local(link, addr.s_addr)) < 0)
992 if ((err = rtnl_link_ipgre_set_remote(link, addr.s_addr)) < 0)
996 if ((err = rtnl_link_ipgre_set_ttl(link, 64)) < 0)
999 if((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
1002 rtnl_link_put(link);
1013 extern int rtnl_link_sit_set_link(struct rtnl_link *link, uint32_t index);
1014 extern uint32_t rtnl_link_sit_get_link(struct rtnl_link *link);
1016 extern int rtnl_link_sit_set_iflags(struct rtnl_link *link, uint16_t iflags);
1017 extern uint16_t rtnl_link_get_iflags(struct rtnl_link *link);
1019 extern int rtnl_link_sit_set_oflags(struct rtnl_link *link, uint16_t oflags);
1020 extern uint16_t rtnl_link_get_oflags(struct rtnl_link *link);
1022 extern int rtnl_link_sit_set_ikey(struct rtnl_link *link, uint32_t ikey);
1023 extern uint32_t rtnl_link_get_ikey(struct rtnl_link *link);
1025 extern int rtnl_link_sit_set_okey(struct rtnl_link *link, uint32_t okey);
1026 extern uint32_t rtnl_link_get_okey(struct rtnl_link *link)
1028 extern int rtnl_link_sit_set_local(struct rtnl_link *link, uint32_t addr);
1029 extern uint32_t rtnl_link_sit_get_local(struct rtnl_link *link);
1031 extern int rtnl_link_sit_set_remote(struct rtnl_link *link, uint32_t addr);
1032 extern uint32_t rtnl_link_sit_get_remote(struct rtnl_link *link);
1034 extern int rtnl_link_sit_set_ttl(struct rtnl_link *link, uint8_t ttl);
1035 extern uint8_t rtnl_link_sit_get_ttl(struct rtnl_link *link);
1037 extern int rtnl_link_sit_set_tos(struct rtnl_link *link, uint8_t tos);
1038 extern uint8_t rtnl_link_sit_get_tos(struct rtnl_link *link);
1040 extern int rtnl_link_sit_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc);
1041 extern uint8_t rtnl_link_sit_get_pmtudisc(struct rtnl_link *link);
1048 struct rtnl_link *link
1051 /* allocate new link object of type vxlan */
1052 if(!(link = rtnl_link_sit_alloc()))
1056 if ((err = rtnl_link_set_name(link, "sit-tun")) < 0)
1059 /* set link index */
1060 if ((err = rtnl_link_sit_set_link(link, if_index)) < 0)
1065 if ((err = rtnl_link_sit_set_local(link, addr.s_addr)) < 0)
1070 if ((err = rtnl_link_sit_set_remote(link, addr.s_addr)) < 0)
1074 if ((err = rtnl_link_sit_set_ttl(link, 64)) < 0)
1077 if((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
1080 rtnl_link_put(link);
1092 extern int rtnl_link_ipvti_set_link(struct rtnl_link *link, uint32_t index);
1093 extern uint32_t rtnl_link_ipvti_get_link(struct rtnl_link *link);
1095 extern int rtnl_link_ipvti_set_ikey(struct rtnl_link *link, uint32_t ikey);
1096 extern uint32_t rtnl_link_get_ikey(struct rtnl_link *link);
1098 extern int rtnl_link_ipvti_set_okey(struct rtnl_link *link, uint32_t okey);
1099 extern uint32_t rtnl_link_get_okey(struct rtnl_link *link)
1101 extern int rtnl_link_ipvti_set_local(struct rtnl_link *link, uint32_t addr);
1102 extern uint32_t rtnl_link_ipvti_get_local(struct rtnl_link *link);
1104 extern int rtnl_link_ipvti_set_remote(struct rtnl_link *link, uint32_t addr);
1105 extern uint32_t rtnl_link_ipvti_get_remote(struct rtnl_link *link);
1112 struct rtnl_link *link
1115 /* allocate new link object of type vxlan */
1116 if(!(link = rtnl_link_ipvti_alloc()))
1120 if ((err = rtnl_link_set_name(link, "ipvti-tun")) < 0)
1123 /* set link index */
1124 if ((err = rtnl_link_ipvti_set_link(link, if_index)) < 0)
1129 if ((err = rtnl_link_ipvti_set_local(link, addr.s_addr)) < 0)
1134 if ((err = rtnl_link_ipvti_set_remote(link, addr.s_addr)) < 0)
1137 if((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0)
1140 rtnl_link_put(link);
1151 extern int rtnl_link_ip6_tnl_set_link(struct rtnl_link *link, uint32_t index);
1152 extern uint32_t rtnl_link_ip6_tnl_get_link(struct rtnl_link *link);
1154 extern int rtnl_link_ip6_tnl_set_local(struct rtnl_link *link, struct in6_addr *);
1155 extern int rtnl_link_ip6_tnl_get_local(struct rtnl_link *link, struct in6_addr *);
1157 extern int rtnl_link_ip6_tnl_set_remote(struct rtnl_link *link, struct in6_addr *);
1158 extern int rtnl_link_ip6_tnl_get_remote(struct rtnl_link *link, struct in6_addr *);
1160 extern int rtnl_link_ip6_tnl_set_ttl(struct rtnl_link *link, uint8_t ttl);
1161 extern uint8_t rtnl_link_ip6_tnl_get_ttl(struct rtnl_link *link);
1163 extern int rtnl_link_ip6_tnl_set_tos(struct rtnl_link *link, uint8_t tos);
1164 extern uint8_t rtnl_link_ip6_tnl_get_tos(struct rtnl_link *link);
1166 extern int rtnl_link_ip6_tnl_set_encaplimit(struct rtnl_link *link, uint8_t encap_limit);
1167 extern uint8_t rtnl_link_ip6_tnl_get_encaplimit(struct rtnl_link *link);
1169 extern int rtnl_link_ip6_tnl_set_flags(struct rtnl_link *link, uint32_t flags);
1170 extern uint32_t rtnl_link_ip6_tnl_get_flags(struct rtnl_link *link);
1172 extern uint32_t rtnl_link_ip6_tnl_get_flowinfo(struct rtnl_link *link);
1173 extern int rtnl_link_ip6_tnl_set_flowinfo(struct rtnl_link *link, uint32_t flowinfo);
1175 extern int rtnl_link_ip6_tnl_set_proto(struct rtnl_link *link, uint8_t proto);
1176 extern uint8_t rtnl_link_ip6_tnl_get_proto(struct rtnl_link *link);
1183 struct rtnl_link *link
1186 link = rtnl_link_ip6_tnl_alloc();
1188 rtnl_link_set_name(link, "ip6tnl-tun");
1189 rtnl_link_ip6_tnl_set_link(link, if_index);
1192 rtnl_link_ip6_tnl_set_local(link, &addr);
1195 rtnl_link_ip6_tnl_set_remote(link, &addr);
1197 rtnl_link_add(sk, link, NLM_F_CREATE);
1198 rtnl_link_put(link);
1318 when setting the interface index. It stores the reference to the link
1325 void rtnl_tc_set_link(struct rtnl_tc *tc, struct rtnl_link *link);
1329 Link Type::
1330 The link type specifies the kind of link that is used by the network
1369 will be transmitted. The value is derived from the link specified
1371 If no link and MTU is specified, the value defaults to 1500