summaryrefslogtreecommitdiff
path: root/src/network/networkd-address-label.h
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2017-04-25 16:06:50 +0530
committerSusant Sahani <susant@redhat.com>2017-04-26 16:00:44 +0530
commit95b74ef6ea03632e050cddd99db8b42f30e6e824 (patch)
treee6d0e68ac29dfb9aac2ea2256a2dc5bfd0eac729 /src/network/networkd-address-label.h
parent30746d6088ccfec802972fd5ee12a1e945a0f69b (diff)
downloadsystemd-95b74ef6ea03632e050cddd99db8b42f30e6e824.tar.gz
systemd-95b74ef6ea03632e050cddd99db8b42f30e6e824.tar.bz2
systemd-95b74ef6ea03632e050cddd99db8b42f30e6e824.zip
networkd: add support for address label
IPv6 address labels are used for address selection; they are described in RFC 3484. Precedence is managed by userspace, and only the label itself is stored in the kernel. enp0s25.network [Match] Name=enp0s25 [Network] DHCP=yes Address = 2001:db8:f00:baa::b [AddressLabel] Label=199 Prefix=2001:db8:41::/64 [AddressLabel] Label=11 Prefix=2001:db8:31::/64 [AddressLabel] Label=123 Prefix=2001:db8:21::/64 [AddressLabel] Label=124 Prefix=2001:db8:11::/64 [sus@maximus label]$ ip addrlabel list prefix ::1/128 label 0 prefix ::/96 label 3 prefix ::ffff:0.0.0.0/96 label 4 prefix 2001:db8:41::/64 dev enp0s25 label 199 prefix 2001:db8:31::/64 dev enp0s25 label 11 prefix 2001:db8:21::/64 dev enp0s25 label 123 prefix 2001:db8:11::/64 dev enp0s25 label 124 prefix 2001::/32 label 6 prefix 2001:10::/28 label 7 prefix 3ffe::/16 label 12 prefix 2002::/16 label 2 prefix fec0::/10 label 11 prefix fc00::/7 label 5 prefix ::/0 label 1
Diffstat (limited to 'src/network/networkd-address-label.h')
-rw-r--r--src/network/networkd-address-label.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/network/networkd-address-label.h b/src/network/networkd-address-label.h
new file mode 100644
index 0000000000..05bb24924c
--- /dev/null
+++ b/src/network/networkd-address-label.h
@@ -0,0 +1,59 @@
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2017 Susant Sahani
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <inttypes.h>
+#include <stdbool.h>
+
+#include "in-addr-util.h"
+
+typedef struct AddressLabel AddressLabel;
+
+#include "networkd-link.h"
+#include "networkd-network.h"
+
+typedef struct Network Network;
+typedef struct Link Link;
+typedef struct NetworkConfigSection NetworkConfigSection;
+
+struct AddressLabel {
+ Network *network;
+ Link *link;
+ NetworkConfigSection *section;
+
+ int family;
+ unsigned char prefixlen;
+ uint32_t label;
+
+ union in_addr_union in_addr;
+
+ LIST_FIELDS(AddressLabel, labels);
+};
+
+int address_label_new(AddressLabel **ret);
+void address_label_free(AddressLabel *label);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(AddressLabel*, address_label_free);
+#define _cleanup_address_label_free_ _cleanup_(address_label_freep)
+
+int address_label_configure(AddressLabel *address, Link *link, sd_netlink_message_handler_t callback, bool update);
+
+int config_parse_address_label(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_address_label_prefix(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);