[systemd-commits] 3 commits - man/systemd.network.xml src/libsystemd-network src/network src/systemd TODO

Tom Gundersen tomegun at kemper.freedesktop.org
Mon Jul 14 02:39:31 PDT 2014


 TODO                                     |    1 
 man/systemd.network.xml                  |   12 ++++++++++
 src/libsystemd-network/dhcp-protocol.h   |    1 
 src/libsystemd-network/sd-dhcp-client.c  |   28 ++++++++++++++++++++++++
 src/network/networkd-link.c              |   15 +++++++++---
 src/network/networkd-network-gperf.gperf |    3 +-
 src/network/networkd-network.c           |    1 
 src/network/networkd-route.c             |   36 +++++++++++++++++++++++++++++++
 src/network/networkd.h                   |    5 ++++
 src/systemd/sd-dhcp-client.h             |    1 
 10 files changed, 97 insertions(+), 6 deletions(-)

New commits:
commit edb85f0d8d0a84f27308a3728f3fde3c52b9dce2
Author: Susant Sahani <susant at redhat.com>
Date:   Mon Jul 14 13:34:18 2014 +0530

    networkd: dhcp add vendor class indentifier option 60
    
    Vendor Class Identifier be used by DHCP clients to identify
    their vendor type and configuration. When using this option,
    vendors can define their own specific identifier values, such
    as to convey a particular hardware or operating system
    configuration or other identifying information.
    
    Vendor-specified DHCP options—features that let administrators assign
    separate options to clients with similar configuration requirements.
    For example, if DHCP-aware clients for example we want to separate
    different gateway and option for different set of people
    (dev/test/hr/finance) in a org or devices for example web/database
    servers or let's say in a embedded device etc and require a different
    default gateway or DNS server than the rest of clients.

diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 738977e..3c4fdd2 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -446,6 +446,12 @@
                                                 if, say, the root filesystem relies on this connection. Defaults to false.</para>
                                         </listitem>
                                 </varlistentry>
+                                    <varlistentry>
+                                        <term><varname>VendorClassIdentifier=</varname></term>
+                                        <listitem>
+                                                <para>The vendor class identifier used to identify vendor type and configuration.</para>
+                                        </listitem>
+                                </varlistentry>
                        </variablelist>
 
         </refsect1>
diff --git a/src/libsystemd-network/dhcp-protocol.h b/src/libsystemd-network/dhcp-protocol.h
index 8cbd98e..7c06b5a 100644
--- a/src/libsystemd-network/dhcp-protocol.h
+++ b/src/libsystemd-network/dhcp-protocol.h
@@ -131,6 +131,7 @@ enum {
         DHCP_OPTION_MAXIMUM_MESSAGE_SIZE        = 57,
         DHCP_OPTION_RENEWAL_T1_TIME             = 58,
         DHCP_OPTION_REBINDING_T2_TIME           = 59,
+        DHCP_OPTION_VENDOR_CLASS_IDENTIFIER     = 60,
         DHCP_OPTION_CLIENT_IDENTIFIER           = 61,
         DHCP_OPTION_CLASSLESS_STATIC_ROUTE      = 121,
         DHCP_OPTION_END                         = 255,
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 6b19666..3c38993 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -57,6 +57,7 @@ struct sd_dhcp_client {
                 struct ether_addr mac_addr;
         } _packed_ client_id;
         char *hostname;
+        char *vendor_class_identifier;
         uint32_t xid;
         usec_t start_time;
         uint16_t secs;
@@ -200,6 +201,23 @@ int sd_dhcp_client_set_hostname(sd_dhcp_client *client,
         return 0;
 }
 
+int sd_dhcp_client_set_vendor_class_identifier(sd_dhcp_client *client,
+                                               const char *vci) {
+        char *new_vci = NULL;
+
+        assert_return(client, -EINVAL);
+
+        new_vci = strdup(vci);
+        if (!new_vci)
+                return -ENOMEM;
+
+        free(client->vendor_class_identifier);
+
+        client->vendor_class_identifier = new_vci;
+
+        return 0;
+}
+
 int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) {
         assert_return(client, -EINVAL);
         assert_return(ret, -EINVAL);
@@ -419,6 +437,15 @@ static int client_send_discover(sd_dhcp_client *client) {
                         return r;
         }
 
+        if (client->vendor_class_identifier) {
+                r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
+                                       DHCP_OPTION_VENDOR_CLASS_IDENTIFIER,
+                                       strlen(client->vendor_class_identifier),
+                                       client->vendor_class_identifier);
+                if (r < 0)
+                        return r;
+        }
+
         r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
                                DHCP_OPTION_END, 0, NULL);
         if (r < 0)
@@ -1406,6 +1433,7 @@ sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client) {
 
                 free(client->req_opts);
                 free(client->hostname);
+                free(client->vendor_class_identifier);
                 free(client);
         }
 
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 5f6c22a..9e057ce 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2023,6 +2023,13 @@ static int link_configure(Link *link) {
                                         return r;
                         }
                 }
+
+                if (link->network->dhcp_vendor_class_identifier) {
+                        r = sd_dhcp_client_set_vendor_class_identifier(link->dhcp_client,
+                                                                       link->network->dhcp_vendor_class_identifier);
+                        if (r < 0)
+                                return r;
+                }
         }
 
         if (link->network->dhcp_server) {
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 50cb0f8..5c1c013 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -51,6 +51,7 @@ DHCP.UseDomainName,          config_parse_bool,                  0,
 DHCP.UseRoutes,              config_parse_bool,                  0,                             offsetof(Network, dhcp_routes)
 DHCP.SendHostname,           config_parse_bool,                  0,                             offsetof(Network, dhcp_sendhost)
 DHCP.CriticalConnection,     config_parse_bool,                  0,                             offsetof(Network, dhcp_critical)
+DHCP.VendorClassIdentifier,  config_parse_string,                0,                             offsetof(Network, dhcp_vendor_class_identifier)
 /* backwards compatibility: do not add new entries to this section */
 DHCPv4.UseDNS,               config_parse_bool,                  0,                             offsetof(Network, dhcp_dns)
 DHCPv4.UseMTU,               config_parse_bool,                  0,                             offsetof(Network, dhcp_mtu)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 9f6de18..c108ad2 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -166,6 +166,7 @@ void network_free(Network *network) {
         free(network->match_name);
 
         free(network->description);
+        free(network->dhcp_vendor_class_identifier);
 
         while ((address = network->ntp)) {
                 LIST_REMOVE(addresses, network->ntp, address);
diff --git a/src/network/networkd.h b/src/network/networkd.h
index aca3b8d..0f0ecd5 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -175,6 +175,8 @@ struct Network {
         char *match_driver;
         char *match_type;
         char *match_name;
+        char *dhcp_vendor_class_identifier;
+
         Condition *match_host;
         Condition *match_virt;
         Condition *match_kernel;
diff --git a/src/systemd/sd-dhcp-client.h b/src/systemd/sd-dhcp-client.h
index c3ea059..9ab6105 100644
--- a/src/systemd/sd-dhcp-client.h
+++ b/src/systemd/sd-dhcp-client.h
@@ -52,6 +52,7 @@ int sd_dhcp_client_set_index(sd_dhcp_client *client, int interface_index);
 int sd_dhcp_client_set_mac(sd_dhcp_client *client,
                            const struct ether_addr *addr);
 int sd_dhcp_client_set_hostname(sd_dhcp_client *client, const char *hostname);
+int sd_dhcp_client_set_vendor_class_identifier(sd_dhcp_client *client, const char *vci);
 int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret);
 
 int sd_dhcp_client_stop(sd_dhcp_client *client);

commit 5d8e593dce074bff966fc0a46579c61b4f3bc33a
Author: Susant Sahani <susant at redhat.com>
Date:   Thu Jul 10 23:09:58 2014 +0530

    networkd: make metric of routes configurable
    
    Now route metric can be configuted via conf file:
    
    example conf:
    
    [Match]
    Name=em1
    
    [Route]
    Gateway=192.168.1.12
    Metric=10
    
    Test:
    ip route output
    default via 192.168.1.12 dev em1 metric 10
    
    [tomegun: squash TODO update and reword man page a bit]

diff --git a/TODO b/TODO
index 4bdf6c3..877321f 100644
--- a/TODO
+++ b/TODO
@@ -624,7 +624,6 @@ Features:
    - properly handle routerless dhcp leases
    - default to DHCP unicast, but make broadcast opt-in. detect devices that needs broadcast and opt-in automatically (needs kernel patch?)
    - add more attribute support for SIT tunnel
-   - make metric of routes configurable
    - work with non-ethernet devices
    - add support for more bond options
 
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index c13085c..738977e 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -389,6 +389,12 @@
                                                 prefixlength. If ommitted, a full-length host route is assumed.</para>
                                         </listitem>
                                 </varlistentry>
+                                <varlistentry>
+                                        <term><varname>Metric=</varname></term>
+                                        <listitem>
+                                                <para>The metric of the route. An unsigned integer</para>
+                                        </listitem>
+                                </varlistentry>
                         </variablelist>
         </refsect1>
 
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index c821ead..50cb0f8 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -43,7 +43,7 @@ Address.Peer,                config_parse_address,               0,
 Address.Broadcast,           config_parse_broadcast,             0,                             0
 Address.Label,               config_parse_label,                 0,                             0
 Route.Gateway,               config_parse_gateway,               0,                             0
-Route.Destination,           config_parse_destination,           0,                             0
+Route.Metric,                config_parse_route_priority,        0,                             0
 DHCP.UseDNS,                 config_parse_bool,                  0,                             offsetof(Network, dhcp_dns)
 DHCP.UseMTU,                 config_parse_bool,                  0,                             offsetof(Network, dhcp_mtu)
 DHCP.UseHostname,            config_parse_bool,                  0,                             offsetof(Network, dhcp_hostname)
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index acfe3f0..9e6295f 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -360,3 +360,39 @@ int config_parse_destination(const char *unit,
 
         return 0;
 }
+
+int config_parse_route_priority(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) {
+        Network *network = userdata;
+        _cleanup_route_free_ Route *n = NULL;
+        _cleanup_free_ char *route = NULL;
+        int r;
+
+        assert(filename);
+        assert(section);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = route_new_static(network, section_line, &n);
+        if (r < 0)
+                return r;
+
+        r = config_parse_unsigned(unit, filename, line, section,
+                                  section_line, lvalue, ltype,
+                                  rvalue, &n->metrics, userdata);
+        if (r < 0)
+                return r;
+
+        n = NULL;
+
+        return 0;
+}
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 9132e70..aca3b8d 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -467,6 +467,9 @@ int config_parse_destination(const char *unit, const char *filename, unsigned li
                              const char *section, unsigned section_line, const char *lvalue,
                              int ltype, const char *rvalue, void *data, void *userdata);
 
+int config_parse_route_priority(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);
 /* Address */
 int address_new_static(Network *network, unsigned section, Address **ret);
 int address_new_dynamic(Address **ret);

commit 5bdd314cd9954b605542571490738326f007c46c
Author: Tom Gundersen <teg at jklm.no>
Date:   Mon Jul 14 11:04:13 2014 +0200

    networkd: return 1 from successful event handlers

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 3e35090..5f6c22a 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -596,7 +596,7 @@ static int route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
                                 "ERRNO=%d", -r,
                                 NULL);
 
-        return 0;
+        return 1;
 }
 
 static int link_get_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
@@ -648,7 +648,7 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
                                 link->ifname, strerror(-r),
                                 "ERRNO=%d", -r,
                                 NULL);
-        if (r >= 0) {
+        else if (r >= 0) {
                 /* calling handler directly so take a ref */
                 link_ref(link);
                 link_get_address_handler(rtnl, m, link);
@@ -809,7 +809,7 @@ static int address_update_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userd
                                 "ERRNO=%d", -r,
                                 NULL);
 
-        return 0;
+        return 1;
 }
 
 static int address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
@@ -832,7 +832,7 @@ static int address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdat
                                 "ERRNO=%d", -r,
                                 NULL);
 
-        return 0;
+        return 1;
 }
 
 static int set_hostname_handler(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {



More information about the systemd-commits mailing list