Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
Hi Tom, Regarding your request: Hm, we need to introduce a new administrative state here I think (LINK_STATE_DOWN), and then make sure we don't accidentally leave it in case we get some other event after bringing the interface down. This is a little bit tricky. When we bring the link down it would be easy to change the state to LINK_STATE_DOWN, but when we bring the port up I don’t know how to restore it to the previous state unless I use an additional variable in the link structure to retain the previous state of the port, but this will not look nice I think. Would this be acceptable ? Currently, when a link becomes down, it will have the operational state off. See State: off (configured) below: Would this suffice since however we don't have a corresponding LINK_STATE_UP and from current behavior it seems acceptable to have the port down (operational off) and configured. # networkctl status sw0p3 ● 5: sw0p3 Link File: /usr/lib/systemd/network/99-default.link Network File: /etc/systemd/network/sw0p3.network Type: ether State: off (configured) Driver: fm6k MTU: 1500 Carrier Bound To: sw0p2 sw0p1 # Best Regards, Alin -Original Message- From: Zbigniew Jędrzejewski-Szmek [mailto:zbys...@in.waw.pl] Sent: Saturday, February 14, 2015 3:34 PM To: Rauta, Alin Cc: Tom Gundersen; Lennart Poettering; systemd Mailing List; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Sat, Feb 14, 2015 at 03:26:00PM +, Rauta, Alin wrote: Hi guys, Thanks for your input on this. Much appreciated. I'll try handle your remarks in the next patch. Please find my comments below. Best Regards, Alin -Original Message- From: Tom Gundersen [mailto:t...@jklm.no] Sent: Saturday, February 14, 2015 2:50 PM To: Zbigniew Jędrzejewski-Szmek Cc: Rauta, Alin; Lennart Poettering; systemd Mailing List; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Sat, Feb 14, 2015 at 3:05 PM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl wrote: On Fri, Feb 13, 2015 at 10:27:07PM +0100, Tom Gundersen wrote: Hi Alin, Thanks for the patch. This is starting to look pretty good now. I still have some questions/requests regarding some implementation details (below), but hopefully we can get this merged after the next release (trying to stabilize things at the moment). On Tue, Feb 10, 2015 at 12:30 PM, Alin Rauta alin.ra...@intel.com wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to + the current operational down does not follow normal grammar rules. are in an operational down state? +interface. When at least one port has carrier, the current +interface is brought up. +/para Maybe we should make it clear that this is not necessarily a failure (the uplink may be down on purpose), and that the way we propagate it is to set the downlink administrative down. Alin: I will think of something else here. Some other way to describe this. + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Sat, Feb 14, 2015 at 3:05 PM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl wrote: On Fri, Feb 13, 2015 at 10:27:07PM +0100, Tom Gundersen wrote: Hi Alin, Thanks for the patch. This is starting to look pretty good now. I still have some questions/requests regarding some implementation details (below), but hopefully we can get this merged after the next release (trying to stabilize things at the moment). On Tue, Feb 10, 2015 at 12:30 PM, Alin Rauta alin.ra...@intel.com wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the current operational down does not follow normal grammar rules. are in an operational down state? +interface. When at least one port has carrier, the current +interface is brought up. +/para Maybe we should make it clear that this is not necessarily a failure (the uplink may be down on purpose), and that the way we propagate it is to set the downlink administrative down. + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); +} I don't find get_carriers() very clear. At least call it get_carrier_bound_to() or something like that. I must say I agree with Lennart and Zbigniew, we should introduce the API in both directions, and then we can worry about the performance if that turns out to be a problem (worst case all the processing could be hidden in the sd-network library, but I don't think that will be necessary to be honest). _public_ int sd_network_link_get_wildcard_domain(int ifindex) { int r; _cleanup_free_ char *p = NULL, *s = NULL; diff --git a/src/network/networkctl.c b/src/network/networkctl.c index aa83f32..ffb38e8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -22,6 +22,7 @@ #include stdbool.h #include getopt.h #include net/if.h +#include fnmatch.h #include sd-network.h #include sd-rtnl.h @@ -393,6 +394,161 @@ static int get_gateway_description( return -ENODATA; } +static bool is_carrier(const char *ifname, + char **carriers) { + char **i; + + STRV_FOREACH(i, carriers) + if (fnmatch(*i, ifname, 0) == 0) + return true; + + return false; +} + +/* get the links that are bound to this port. */ +static int get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { +_cleanup_free_ LinkInfo *links = NULL; +sd_rtnl_message *i; +size_t size = 0; +size_t c = 0; Why is c size_t? +int r; + +assert(m); +assert(name); + +*down_count = 0; +*downlinks = NULL; Why do you initialize this here? If an error happens, it is nice to not modify output parameters at all. +for (i = m; i; i = sd_rtnl_message_next(i)) { +_cleanup_strv_free_ char **carriers = NULL; +const char *link_name; +int ifindex; + +r = sd_rtnl_message_link_get_ifindex(i, ifindex);
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
Hi guys, Thanks for your input on this. Much appreciated. I'll try handle your remarks in the next patch. Please find my comments below. Best Regards, Alin -Original Message- From: Tom Gundersen [mailto:t...@jklm.no] Sent: Saturday, February 14, 2015 2:50 PM To: Zbigniew Jędrzejewski-Szmek Cc: Rauta, Alin; Lennart Poettering; systemd Mailing List; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Sat, Feb 14, 2015 at 3:05 PM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl wrote: On Fri, Feb 13, 2015 at 10:27:07PM +0100, Tom Gundersen wrote: Hi Alin, Thanks for the patch. This is starting to look pretty good now. I still have some questions/requests regarding some implementation details (below), but hopefully we can get this merged after the next release (trying to stabilize things at the moment). On Tue, Feb 10, 2015 at 12:30 PM, Alin Rauta alin.ra...@intel.com wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the + current operational down does not follow normal grammar rules. are in an operational down state? +interface. When at least one port has carrier, the current +interface is brought up. +/para Maybe we should make it clear that this is not necessarily a failure (the uplink may be down on purpose), and that the way we propagate it is to set the downlink administrative down. Alin: I will think of something else here. Some other way to describe this. + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } I don't find get_carriers() very clear. At least call it get_carrier_bound_to() or something like that. I must say I agree with Lennart and Zbigniew, we should introduce the API in both directions, and then we can worry about the performance if that turns out to be a problem (worst case all the processing could be hidden in the sd-network library, but I don't think that will be necessary to be honest). Alin: I will change the name and provide functions in both directions. _public_ int sd_network_link_get_wildcard_domain(int ifindex) { int r; _cleanup_free_ char *p = NULL, *s = NULL; diff --git a/src/network/networkctl.c b/src/network/networkctl.c index aa83f32..ffb38e8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -22,6 +22,7 @@ #include stdbool.h #include getopt.h #include net/if.h +#include fnmatch.h #include sd-network.h #include sd-rtnl.h @@ -393,6 +394,161 @@ static int get_gateway_description( return -ENODATA; } +static bool is_carrier(const char *ifname, + char **carriers) { + char **i; + + STRV_FOREACH(i, carriers) + if (fnmatch(*i, ifname, 0) == 0) + return true; + + return false; +} + +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { +
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Sat, Feb 14, 2015 at 03:26:00PM +, Rauta, Alin wrote: Hi guys, Thanks for your input on this. Much appreciated. I'll try handle your remarks in the next patch. Please find my comments below. Best Regards, Alin -Original Message- From: Tom Gundersen [mailto:t...@jklm.no] Sent: Saturday, February 14, 2015 2:50 PM To: Zbigniew Jędrzejewski-Szmek Cc: Rauta, Alin; Lennart Poettering; systemd Mailing List; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Sat, Feb 14, 2015 at 3:05 PM, Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl wrote: On Fri, Feb 13, 2015 at 10:27:07PM +0100, Tom Gundersen wrote: Hi Alin, Thanks for the patch. This is starting to look pretty good now. I still have some questions/requests regarding some implementation details (below), but hopefully we can get this merged after the next release (trying to stabilize things at the moment). On Tue, Feb 10, 2015 at 12:30 PM, Alin Rauta alin.ra...@intel.com wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the + current operational down does not follow normal grammar rules. are in an operational down state? +interface. When at least one port has carrier, the current +interface is brought up. +/para Maybe we should make it clear that this is not necessarily a failure (the uplink may be down on purpose), and that the way we propagate it is to set the downlink administrative down. Alin: I will think of something else here. Some other way to describe this. + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } I don't find get_carriers() very clear. At least call it get_carrier_bound_to() or something like that. I must say I agree with Lennart and Zbigniew, we should introduce the API in both directions, and then we can worry about the performance if that turns out to be a problem (worst case all the processing could be hidden in the sd-network library, but I don't think that will be necessary to be honest). Alin: I will change the name and provide functions in both directions. _public_ int sd_network_link_get_wildcard_domain(int ifindex) { int r; _cleanup_free_ char *p = NULL, *s = NULL; diff --git a/src/network/networkctl.c b/src/network/networkctl.c index aa83f32..ffb38e8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -22,6 +22,7 @@ #include stdbool.h #include getopt.h #include net/if.h +#include fnmatch.h #include sd-network.h #include sd-rtnl.h @@ -393,6 +394,161 @@ static int get_gateway_description( return -ENODATA; } +static bool is_carrier(const char *ifname, + char **carriers) { + char **i; + + STRV_FOREACH(i, carriers) + if (fnmatch(*i, ifname, 0) == 0) + return true; + + return false; +} + +/* get the links that are bound to this port. */ static int
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Fri, Feb 13, 2015 at 10:27:07PM +0100, Tom Gundersen wrote: Hi Alin, Thanks for the patch. This is starting to look pretty good now. I still have some questions/requests regarding some implementation details (below), but hopefully we can get this merged after the next release (trying to stabilize things at the moment). On Tue, Feb 10, 2015 at 12:30 PM, Alin Rauta alin.ra...@intel.com wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the current operational down does not follow normal grammar rules. are in an operational down state? +interface. When at least one port has carrier, the current +interface is brought up. +/para Maybe we should make it clear that this is not necessarily a failure (the uplink may be down on purpose), and that the way we propagate it is to set the downlink administrative down. + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); +} I don't find get_carriers() very clear. At least call it get_carrier_bound_to() or something like that. I must say I agree with Lennart and Zbigniew, we should introduce the API in both directions, and then we can worry about the performance if that turns out to be a problem (worst case all the processing could be hidden in the sd-network library, but I don't think that will be necessary to be honest). _public_ int sd_network_link_get_wildcard_domain(int ifindex) { int r; _cleanup_free_ char *p = NULL, *s = NULL; diff --git a/src/network/networkctl.c b/src/network/networkctl.c index aa83f32..ffb38e8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -22,6 +22,7 @@ #include stdbool.h #include getopt.h #include net/if.h +#include fnmatch.h #include sd-network.h #include sd-rtnl.h @@ -393,6 +394,161 @@ static int get_gateway_description( return -ENODATA; } +static bool is_carrier(const char *ifname, + char **carriers) { + char **i; + + STRV_FOREACH(i, carriers) + if (fnmatch(*i, ifname, 0) == 0) + return true; + + return false; +} + +/* get the links that are bound to this port. */ +static int get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { +_cleanup_free_ LinkInfo *links = NULL; +sd_rtnl_message *i; +size_t size = 0; +size_t c = 0; Why is c size_t? +int r; + +assert(m); +assert(name); + +*down_count = 0; +*downlinks = NULL; Why do you initialize this here? If an error happens, it is nice to not modify output parameters at all. +for (i = m; i; i = sd_rtnl_message_next(i)) { +_cleanup_strv_free_ char **carriers = NULL; +const char *link_name; +int ifindex; + +r = sd_rtnl_message_link_get_ifindex(i, ifindex); +if (r 0) +return r; + +r
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
Hi Tom, Any news on this ? Best Regards, Alin -Original Message- From: Lennart Poettering [mailto:lenn...@poettering.net] Sent: Wednesday, February 11, 2015 6:03 PM To: Rauta, Alin Cc: zbys...@in.waw.pl; t...@jklm.no; systemd-devel@lists.freedesktop.org; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Wed, 11.02.15 17:44, Rauta, Alin (alin.ra...@intel.com) wrote: Hi Lennart, +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); In terms of functionality, sd_network_link_get_carriers is actually sd_network_link_get_carrier_bound_to and is applicable to bound to links just like BindCarrier= is available only for bound to links. I wanted to save to systemd run files just minimum info. If I add sd_network_link_get_carrier_bound_by, then each time link_save is called for a link I should query BindCarrier=s for all interfaces to print each link that bounds the current interface. Then, if I rename a link I should call link_save for all available links because the BindCarrier= can be interpreted in another way due to wildcards. Well, one option could be to keep a set of bound_by and bound_to links around for each link, and then just update that each time an interface comes, goes, or changes names. That way you always have direct access to the bound links, and don't have to resolve the globs each time you need them, but only when they actually change? The reason why I figured having two calls for this would be useful is simply to make it easy to write tools like networkctl, which wants to show this information in both directions for each interface... +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Regarding get_uplinks and get_downlinks I can rename them to get_links_bound_to and get_links_bound_by. Would this be fine ? Sure! But before you rework any of this, let's see what Tom has to say, he's the networkd maintainer... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Thu, Feb 12, 2015 at 08:56:00AM +, Rauta, Alin wrote: Well, one option could be to keep a set of bound_by and bound_to links around for each link, and then just update that each time an interface comes, goes, or changes names. Yes, but the updates need to be done for all links and I'm not sure adding this is a good thing. I'm now having 64 links on the switch and I need the failure detection in networkd to be quite fast because however even now it's probably slower due to evaluating dynamically the BindCarrier strings when comparing this with the previous solution with an UFD group monitoring some interfaces and with some internal counters knowing exactly when to issue link_down for an interface. So adding bound_by and bound_to makes the solution even slower. How many times per second will you be avaluating this? Besides this, having only one function sd_network_link_get_carrier_bound_to makes also sense because only the behavior of bond_to links is controlled by this feature. bound_by means almost nothing for an interface. A tool like networkctl may take into account to display only the bound_to links because that's what's relevant. The fact that networkctl displays both bound_to and bound_by it's a good thing, but it doesn't mean each tool should do that. If a link goes down, isn't the bound_by list useful to look at links which need to be checked and potentiallly brought down? Zbyszek /Alin -Original Message- From: Lennart Poettering [mailto:lenn...@poettering.net] Sent: Wednesday, February 11, 2015 6:03 PM To: Rauta, Alin Cc: zbys...@in.waw.pl; t...@jklm.no; systemd-devel@lists.freedesktop.org; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Wed, 11.02.15 17:44, Rauta, Alin (alin.ra...@intel.com) wrote: Hi Lennart, +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); In terms of functionality, sd_network_link_get_carriers is actually sd_network_link_get_carrier_bound_to and is applicable to bound to links just like BindCarrier= is available only for bound to links. I wanted to save to systemd run files just minimum info. If I add sd_network_link_get_carrier_bound_by, then each time link_save is called for a link I should query BindCarrier=s for all interfaces to print each link that bounds the current interface. Then, if I rename a link I should call link_save for all available links because the BindCarrier= can be interpreted in another way due to wildcards. Well, one option could be to keep a set of bound_by and bound_to links around for each link, and then just update that each time an interface comes, goes, or changes names. That way you always have direct access to the bound links, and don't have to resolve the globs each time you need them, but only when they actually change? The reason why I figured having two calls for this would be useful is simply to make it easy to write tools like networkctl, which wants to show this information in both directions for each interface... +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Regarding get_uplinks and get_downlinks I can rename them to get_links_bound_to and get_links_bound_by. Would this be fine ? Sure! But before you rework any of this, let's see what Tom has to say, he's the networkd maintainer... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
Well, one option could be to keep a set of bound_by and bound_to links around for each link, and then just update that each time an interface comes, goes, or changes names. Yes, but the updates need to be done for all links and I'm not sure adding this is a good thing. I'm now having 64 links on the switch and I need the failure detection in networkd to be quite fast because however even now it's probably slower due to evaluating dynamically the BindCarrier strings when comparing this with the previous solution with an UFD group monitoring some interfaces and with some internal counters knowing exactly when to issue link_down for an interface. So adding bound_by and bound_to makes the solution even slower. Besides this, having only one function sd_network_link_get_carrier_bound_to makes also sense because only the behavior of bond_to links is controlled by this feature. bound_by means almost nothing for an interface. A tool like networkctl may take into account to display only the bound_to links because that's what's relevant. The fact that networkctl displays both bound_to and bound_by it's a good thing, but it doesn't mean each tool should do that. /Alin -Original Message- From: Lennart Poettering [mailto:lenn...@poettering.net] Sent: Wednesday, February 11, 2015 6:03 PM To: Rauta, Alin Cc: zbys...@in.waw.pl; t...@jklm.no; systemd-devel@lists.freedesktop.org; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Wed, 11.02.15 17:44, Rauta, Alin (alin.ra...@intel.com) wrote: Hi Lennart, +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); In terms of functionality, sd_network_link_get_carriers is actually sd_network_link_get_carrier_bound_to and is applicable to bound to links just like BindCarrier= is available only for bound to links. I wanted to save to systemd run files just minimum info. If I add sd_network_link_get_carrier_bound_by, then each time link_save is called for a link I should query BindCarrier=s for all interfaces to print each link that bounds the current interface. Then, if I rename a link I should call link_save for all available links because the BindCarrier= can be interpreted in another way due to wildcards. Well, one option could be to keep a set of bound_by and bound_to links around for each link, and then just update that each time an interface comes, goes, or changes names. That way you always have direct access to the bound links, and don't have to resolve the globs each time you need them, but only when they actually change? The reason why I figured having two calls for this would be useful is simply to make it easy to write tools like networkctl, which wants to show this information in both directions for each interface... +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Regarding get_uplinks and get_downlinks I can rename them to get_links_bound_to and get_links_bound_by. Would this be fine ? Sure! But before you rework any of this, let's see what Tom has to say, he's the networkd maintainer... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
В Thu, 12 Feb 2015 15:25:08 +0100 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl пишет: On Thu, Feb 12, 2015 at 12:52:00PM +, Rauta, Alin wrote: Yes, but the updates need to be done for all links and I'm not sure adding this is a good thing. I'm now having 64 links on the switch and I need the failure detection in networkd to be quite fast because however even now it's probably slower due to evaluating dynamically the BindCarrier strings when comparing this with the previous solution with an UFD group monitoring some interfaces and with some internal counters knowing exactly when to issue link_down for an interface. So adding bound_by and bound_to makes the solution even slower. How many times per second will you be avaluating this? Each time an event happens: a link appears, disappears, changes flags or names. Yes, I know the causes. I'm asking how often they can realisticly occur. You misunderstand. It is not how often they occur but how fast reaction is. When (final) uplink goes down we want to bring dependent interfaces down as soon as possible. Besides this, having only one function sd_network_link_get_carrier_bound_to makes also sense because only the behavior of bond_to links is controlled by this feature. bound_by means almost nothing for an interface. A tool like networkctl may take into account to display only the bound_to links because that's what's relevant. The fact that networkctl displays both bound_to and bound_by it's a good thing, but it doesn't mean each tool should do that. If a link goes down, isn't the bound_by list useful to look at links which need to be checked and potentiallly brought down? It can be useful, that's why networkctl has the updates, but are talking about the showing functionality or about the run-time up-down game between interfaces ? The latter. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Thu, Feb 12, 2015 at 12:52:00PM +, Rauta, Alin wrote: Yes, but the updates need to be done for all links and I'm not sure adding this is a good thing. I'm now having 64 links on the switch and I need the failure detection in networkd to be quite fast because however even now it's probably slower due to evaluating dynamically the BindCarrier strings when comparing this with the previous solution with an UFD group monitoring some interfaces and with some internal counters knowing exactly when to issue link_down for an interface. So adding bound_by and bound_to makes the solution even slower. How many times per second will you be avaluating this? Each time an event happens: a link appears, disappears, changes flags or names. Yes, I know the causes. I'm asking how often they can realisticly occur. Besides this, having only one function sd_network_link_get_carrier_bound_to makes also sense because only the behavior of bond_to links is controlled by this feature. bound_by means almost nothing for an interface. A tool like networkctl may take into account to display only the bound_to links because that's what's relevant. The fact that networkctl displays both bound_to and bound_by it's a good thing, but it doesn't mean each tool should do that. If a link goes down, isn't the bound_by list useful to look at links which need to be checked and potentiallly brought down? It can be useful, that's why networkctl has the updates, but are talking about the showing functionality or about the run-time up-down game between interfaces ? The latter. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Tue, 10.02.15 03:30, Alin Rauta (alin.ra...@intel.com) wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the current +interface. When at least one port has carrier, the current +interface is brought up. +/para + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); +} + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); This would then allow querying the list of interfaces currently bound to the carrier of the interface you specify, as well as the list of interfaces the network currently applied to the interface you specify is bound to. +/* get the links that are bound to this port. */ +static int get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Hmm, maybe we should agree on one nomenclature here. So far I kinda preferred calling these things bound by and bound to. I figure the terms downlinks and uplink are common too. We should really stick to one set of terms here. I personally find bound by and bound to more descriptive I must say. I'll leave the rest to Tom. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
On Wed, 11.02.15 17:44, Rauta, Alin (alin.ra...@intel.com) wrote: Hi Lennart, +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); In terms of functionality, sd_network_link_get_carriers is actually sd_network_link_get_carrier_bound_to and is applicable to bound to links just like BindCarrier= is available only for bound to links. I wanted to save to systemd run files just minimum info. If I add sd_network_link_get_carrier_bound_by, then each time link_save is called for a link I should query BindCarrier=s for all interfaces to print each link that bounds the current interface. Then, if I rename a link I should call link_save for all available links because the BindCarrier= can be interpreted in another way due to wildcards. Well, one option could be to keep a set of bound_by and bound_to links around for each link, and then just update that each time an interface comes, goes, or changes names. That way you always have direct access to the bound links, and don't have to resolve the globs each time you need them, but only when they actually change? The reason why I figured having two calls for this would be useful is simply to make it easy to write tools like networkctl, which wants to show this information in both directions for each interface... +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Regarding get_uplinks and get_downlinks I can rename them to get_links_bound_to and get_links_bound_by. Would this be fine ? Sure! But before you rework any of this, let's see what Tom has to say, he's the networkd maintainer... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
Hi Lennart, +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); In terms of functionality, sd_network_link_get_carriers is actually sd_network_link_get_carrier_bound_to and is applicable to bound to links just like BindCarrier= is available only for bound to links. I wanted to save to systemd run files just minimum info. If I add sd_network_link_get_carrier_bound_by, then each time link_save is called for a link I should query BindCarrier=s for all interfaces to print each link that bounds the current interface. Then, if I rename a link I should call link_save for all available links because the BindCarrier= can be interpreted in another way due to wildcards. I would prefer using only one function and change the name as you suggested sd_network_link_get_carrier_bound_to. Do you agree ? +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Regarding get_uplinks and get_downlinks I can rename them to get_links_bound_to and get_links_bound_by. Would this be fine ? Best Regards, Alin -Original Message- From: Lennart Poettering [mailto:lenn...@poettering.net] Sent: Wednesday, February 11, 2015 4:54 PM To: Rauta, Alin Cc: zbys...@in.waw.pl; t...@jklm.no; systemd-devel@lists.freedesktop.org; Kinsella, Ray Subject: Re: [PATCH v3] Added support for Uplink Failure Detection using BindCarrier On Tue, 10.02.15 03:30, Alin Rauta (alin.ra...@intel.com) wrote: --- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the current +interface. When at least one port has carrier, the current +interface is brought up. +/para + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); } + I think it would be better to have two calls here: int sd_network_link_get_carrier_bound_to(int ifindex, int **others); int sd_network_link_get_carrier_bound_by(int ifindex, int **others); This would then allow querying the list of interfaces currently bound to the carrier of the interface you specify, as well as the list of interfaces the network currently applied to the interface you specify is bound to. +/* get the links that are bound to this port. */ static int +get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { Hmm, maybe we should agree on one nomenclature here. So far I kinda preferred calling these things bound by and bound to. I figure the terms downlinks and uplink are common too. We should really stick to one set of terms here. I personally find bound by and bound to more descriptive I must say. I'll leave the rest to Tom. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel
[systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
Hi Zbyszek, Thanks for your review. I've handled your remarks. Let me know what you think. Best Regards, Alin Alin Rauta (1): Added support for Uplink Failure Detection using BindCarrier man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) -- 1.9.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v3] Added support for Uplink Failure Detection using BindCarrier
--- man/systemd.network.xml | 11 ++ src/libsystemd/sd-network/sd-network.c | 4 + src/network/networkctl.c | 211 --- src/network/networkd-link.c | 123 +- src/network/networkd-link.h | 1 + src/network/networkd-manager.c | 7 + src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 10 ++ src/network/networkd.h | 2 +- src/systemd/sd-network.h | 3 + 10 files changed, 355 insertions(+), 18 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9b3a92d..8b2ca4e 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -270,6 +270,17 @@ /listitem /varlistentry varlistentry + termvarnameBindCarrier=/varname/term + listitem +paraA port or a list of ports. When set, controls the +behaviour of the current interface. When all ports in the list +are operational down, the failure is propagated to the current +interface. When at least one port has carrier, the current +interface is brought up. +/para + /listitem +/varlistentry +varlistentry termvarnameAddress=/varname/term listitem paraA static IPv4 or IPv6 address and its prefix length, diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index c735cac..b574d19 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -264,6 +264,10 @@ _public_ int sd_network_link_get_domains(int ifindex, char ***ret) { return network_get_link_strv(DOMAINS, ifindex, ret); } +_public_ int sd_network_link_get_carriers(int ifindex, char ***ret) { +return network_get_link_strv(CARRIERS, ifindex, ret); +} + _public_ int sd_network_link_get_wildcard_domain(int ifindex) { int r; _cleanup_free_ char *p = NULL, *s = NULL; diff --git a/src/network/networkctl.c b/src/network/networkctl.c index aa83f32..ffb38e8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -22,6 +22,7 @@ #include stdbool.h #include getopt.h #include net/if.h +#include fnmatch.h #include sd-network.h #include sd-rtnl.h @@ -393,6 +394,161 @@ static int get_gateway_description( return -ENODATA; } +static bool is_carrier(const char *ifname, + char **carriers) { + char **i; + + STRV_FOREACH(i, carriers) + if (fnmatch(*i, ifname, 0) == 0) + return true; + + return false; +} + +/* get the links that are bound to this port. */ +static int get_downlinks(const char *name, + sd_rtnl_message *m, + LinkInfo **downlinks, + int *down_count) { +_cleanup_free_ LinkInfo *links = NULL; +sd_rtnl_message *i; +size_t size = 0; +size_t c = 0; +int r; + +assert(m); +assert(name); + +*down_count = 0; +*downlinks = NULL; + +for (i = m; i; i = sd_rtnl_message_next(i)) { +_cleanup_strv_free_ char **carriers = NULL; +const char *link_name; +int ifindex; + +r = sd_rtnl_message_link_get_ifindex(i, ifindex); +if (r 0) +return r; + +r = sd_rtnl_message_read_string(i, IFLA_IFNAME, link_name); +if (r 0) +return r; + +r = sd_network_link_get_carriers(ifindex, carriers); +if (r == -ENODATA || strv_isempty(carriers)) +continue; + +if (r 0) { +log_warning(Failed to get carrier list for port: %s, name); +continue; +} + +if (is_carrier(name, carriers)) { + if (!GREEDY_REALLOC(links, size, c+1)) + return -ENOMEM; + + links[c].name = link_name; + c++; +} +} + +*downlinks = links; +*down_count = (int) c; + +links = NULL; + +return 0; +} + +/* get the links to which current port is bound to. */ +static int get_uplinks(int ifindex, + sd_rtnl_message *m, + LinkInfo **uplinks, + int *up_count) { +_cleanup_free_ LinkInfo *links = NULL; +_cleanup_strv_free_ char **carriers = NULL; +sd_rtnl_message *i; +size_t size = 0, c = 0; +int r; + +assert(m); + +*up_count = 0; +*uplinks = NULL; + +/* check if this port has carriers. */ +r =