Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On Fri, 25.04.14 19:36, Tom Gundersen (t...@jklm.no) wrote: [sorry for breaking the quoting, hopefully it is clear who said what] I actually think this is the correct way to do it, as the addresses (which I assume is what Jóhann is objecting to?) are properties of the link (similar to mac addresses, mtu, etc) rather than regular ip addresses that you can configure for normal devices. Or maybe I'm missing something? Anyone else have any input on this? This is solely about whether Local= and Remote= belong in .netdev? I am pretty sure they do, after all this is a weird setup: a tunnel is something where the link level is actually the network level of the underlying stack. Hence I think it is right to configure the low-level local and remot IP addresses of the tunnel in .netdev, as long as the high-level local/remote IP addresses of the tunnel stay in .network, if what I write here makes any sense... 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 1/1] networkd: Introduce ipip tunnel
On Mon, Apr 28, 2014 at 5:53 PM, Lennart Poettering lenn...@poettering.net wrote: This is solely about whether Local= and Remote= belong in .netdev? That's my take. I am pretty sure they do, after all this is a weird setup: a tunnel is something where the link level is actually the network level of the underlying stack. Hence I think it is right to configure the low-level local and remot IP addresses of the tunnel in .netdev, as long as the high-level local/remote IP addresses of the tunnel stay in .network, if what I write here makes any sense... Then we agree. -t ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On Fri, Apr 11, 2014 at 6:29 PM, Susant Sahani sus...@redhat.com wrote: On 04/08/2014 12:54 PM, Jóhann B. Guðmundsson wrote: On 04/08/2014 03:22 AM, Susant Sahani wrote: file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun I think this is worse from previous example since now you have moved the network definitions out from the network file and into the net device file. Well thanks for the comment . I am open for the change . Leaving tom to comment on this . [sorry for breaking the quoting, hopefully it is clear who said what] I actually think this is the correct way to do it, as the addresses (which I assume is what Jóhann is objecting to?) are properties of the link (similar to mac addresses, mtu, etc) rather than regular ip addresses that you can configure for normal devices. Or maybe I'm missing something? Anyone else have any input on this? If no one else objects I'll merge this (and I'll fix up Zbiginew's comment as I do so, so no need to resend just for that). Cheers, Tom ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On Tue, Apr 08, 2014 at 08:52:51AM +0530, Susant Sahani wrote: This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 14 +++ src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 169 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 ++ src/network/networkd.h| 27 + 12 files changed, 323 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); +if (r = 0) +r = 0; +else +r = -1; Afaict, kmod_module_probe_insert_module returns normal negative-errno style errors, the same as functions in systemd. Please don't use a meaningless constant, and use the errors returned by kmod_module_probe_insert_module. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On 04/09/2014 01:33 AM, Umut Tezduyar Lindskog wrote: Hi, Few minor suggestions, if you care. Hi sorry for replying late :) On Tue, Apr 8, 2014 at 5:22 AM, Susant Sahani sus...@redhat.com wrote: This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 14 +++ src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 169 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 ++ src/network/networkd.h| 27 + 12 files changed, 323 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); Small optimization but maybe move stuct kmod_module *mod; outside of the for each. Well The compiler is intelligent enough to do so . and the stack does not grow as you think (i am guessing this is what you meant ) + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); If r is -1 from previous run, we are overriding it here. +if (r = 0) +r = 0; +else +r = -1; + +kmod_module_unref(mod); +} + +kmod_module_unref_list(modlist); + +return r; +} diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 65cd0d7..28f53b9 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -24,6 +24,7 @@ #include netinet/ether.h #include netinet/in.h #include stdbool.h +#include libkmod.h #include udev.h #include condition-util.h @@ -65,3 +66,5 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, int net_parse_inaddr(const char *address, unsigned char *family, void *dst); int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); + +int load_module(struct kmod_ctx *ctx, const char *mod_name); diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c index 44ac5ec..96467a3 100644 --- a/src/libsystemd/sd-rtnl/rtnl-types.c +++ b/src/libsystemd/sd-rtnl/rtnl-types.c @@ -104,8 +104,8 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = { [IFLA_IPTUN_LINK]= { .type = NLA_U32 }, -[IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, -[IFLA_IPTUN_REMOTE] = { .type = NLA_U32 }, +[IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR }, +[IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR }, [IFLA_IPTUN_TTL] = { .type = NLA_U8 }, [IFLA_IPTUN_TOS] = { .type = NLA_U8 }, [IFLA_IPTUN_PMTUDISC]= { .type =
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On 04/08/2014 12:54 PM, Jóhann B. Guðmundsson wrote: On 04/08/2014 03:22 AM, Susant Sahani wrote: file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun I think this is worse from previous example since now you have moved the network definitions out from the network file and into the net device file. Well thanks for the comment . I am open for the change . Leaving tom to comment on this . The best way to define this from my pov is like this since the tunnel is the network device type aka Kind=tunnel and the mode is the operation mode of that tunnel ||tunnel0|.netdev| |[NetDev] Name=|||tunnel0| Kind=tunnel ||[Match] Name=enp2s0 .network [Network] |||# one of the following| Mode=ipip | gre | sit | isatap | vti -- Address=192.168.0.15/24 Gateway=192.168.0.1| Or |tunnel0.netdev| |[NetDev] Name=|||tunnel0| Kind=tunnel ||[Match] Name=enp2s0 .network [Network] |||# one of the following| Mode=ipip | gre | sit | isatap | vti -- ||DHCP=yes| or if you want to be consistent with how it's done with bridging you would swap the Mode= in the [Network] section to Tunnel=|ipip | gre | sit | isatap | vti| JBG Thanks, Susant ___ 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 1/1] networkd: Introduce ipip tunnel
On 04/08/2014 03:22 AM, Susant Sahani wrote: file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun I think this is worse from previous example since now you have moved the network definitions out from the network file and into the net device file. The best way to define this from my pov is like this since the tunnel is the network device type aka Kind=tunnel and the mode is the operation mode of that tunnel ||tunnel0|.netdev| |[NetDev] Name=|||tunnel0| Kind=tunnel ||[Match] Name=enp2s0 .network [Network] |||# one of the following| Mode=ipip | gre | sit | isatap | vti -- Address=192.168.0.15/24 Gateway=192.168.0.1| Or |tunnel0.netdev| |[NetDev] Name=|||tunnel0| Kind=tunnel ||[Match] Name=enp2s0 .network [Network] |||# one of the following| Mode=ipip | gre | sit | isatap | vti -- ||DHCP=yes| or if you want to be consistent with how it's done with bridging you would swap the Mode= in the [Network] section to Tunnel=|ipip | gre | sit | isatap | vti| JBG ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
Hi, Few minor suggestions, if you care. On Tue, Apr 8, 2014 at 5:22 AM, Susant Sahani sus...@redhat.com wrote: This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 14 +++ src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 169 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 ++ src/network/networkd.h| 27 + 12 files changed, 323 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); Small optimization but maybe move stuct kmod_module *mod; outside of the for each. + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); If r is -1 from previous run, we are overriding it here. +if (r = 0) +r = 0; +else +r = -1; + +kmod_module_unref(mod); +} + +kmod_module_unref_list(modlist); + +return r; +} diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 65cd0d7..28f53b9 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -24,6 +24,7 @@ #include netinet/ether.h #include netinet/in.h #include stdbool.h +#include libkmod.h #include udev.h #include condition-util.h @@ -65,3 +66,5 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, int net_parse_inaddr(const char *address, unsigned char *family, void *dst); int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); + +int load_module(struct kmod_ctx *ctx, const char *mod_name); diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c index 44ac5ec..96467a3 100644 --- a/src/libsystemd/sd-rtnl/rtnl-types.c +++ b/src/libsystemd/sd-rtnl/rtnl-types.c @@ -104,8 +104,8 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = { [IFLA_IPTUN_LINK]= { .type = NLA_U32 }, -[IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, -[IFLA_IPTUN_REMOTE] = { .type = NLA_U32 }, +[IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR }, +[IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR }, [IFLA_IPTUN_TTL] = { .type = NLA_U8 }, [IFLA_IPTUN_TOS] = { .type = NLA_U8 }, [IFLA_IPTUN_PMTUDISC]= { .type = NLA_U8 }, diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 63d253d..848eddd 100644 ---
[systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 19 src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 175 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 + src/network/networkd.h| 27 + 12 files changed, 334 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); +if (r = 0) +r = 0; +else +r = -1; + +kmod_module_unref(mod); +} + +kmod_module_unref_list(modlist); + +return r; +} diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 65cd0d7..28f53b9 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -24,6 +24,7 @@ #include netinet/ether.h #include netinet/in.h #include stdbool.h +#include libkmod.h #include udev.h #include condition-util.h @@ -65,3 +66,5 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, int net_parse_inaddr(const char *address, unsigned char *family, void *dst); int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); + +int load_module(struct kmod_ctx *ctx, const char *mod_name); diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c index 44ac5ec..96467a3 100644 --- a/src/libsystemd/sd-rtnl/rtnl-types.c +++ b/src/libsystemd/sd-rtnl/rtnl-types.c @@ -104,8 +104,8 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = { [IFLA_IPTUN_LINK]= { .type = NLA_U32 }, -[IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, -[IFLA_IPTUN_REMOTE] = { .type = NLA_U32 }, +[IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR }, +[IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR }, [IFLA_IPTUN_TTL] = { .type = NLA_U8 }, [IFLA_IPTUN_TOS] = { .type = NLA_U8 }, [IFLA_IPTUN_PMTUDISC]= { .type = NLA_U8 }, diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 63d253d..848eddd 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1207,7 +1207,9 @@ static int link_enter_enslave(Link *link) { link_save(link); -if (!link-network-bridge !link-network-bond +if (!link-network-bridge +!link-network-bond +!link-network-tunnel hashmap_isempty(link-network-vlans) hashmap_isempty(link-network-macvlans)) return
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On Mon, Apr 7, 2014 at 9:44 AM, Susant Sahani sus...@redhat.com wrote: This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 19 src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 175 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 + src/network/networkd.h| 27 + 12 files changed, 334 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); +if (r = 0) +r = 0; +else +r = -1; + +kmod_module_unref(mod); +} + +kmod_module_unref_list(modlist); + +return r; +} diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 65cd0d7..28f53b9 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -24,6 +24,7 @@ #include netinet/ether.h #include netinet/in.h #include stdbool.h +#include libkmod.h #include udev.h #include condition-util.h @@ -65,3 +66,5 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, int net_parse_inaddr(const char *address, unsigned char *family, void *dst); int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); + +int load_module(struct kmod_ctx *ctx, const char *mod_name); diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c index 44ac5ec..96467a3 100644 --- a/src/libsystemd/sd-rtnl/rtnl-types.c +++ b/src/libsystemd/sd-rtnl/rtnl-types.c @@ -104,8 +104,8 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = { [IFLA_IPTUN_LINK]= { .type = NLA_U32 }, -[IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, -[IFLA_IPTUN_REMOTE] = { .type = NLA_U32 }, +[IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR }, +[IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR }, [IFLA_IPTUN_TTL] = { .type = NLA_U8 }, [IFLA_IPTUN_TOS] = { .type = NLA_U8 }, [IFLA_IPTUN_PMTUDISC]= { .type = NLA_U8 }, diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 63d253d..848eddd 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1207,7 +1207,9 @@ static int link_enter_enslave(Link *link) { link_save(link); -if (!link-network-bridge !link-network-bond +if (!link-network-bridge +
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On 04/07/2014 02:39 PM, Tom Gundersen wrote: On Mon, Apr 7, 2014 at 9:44 AM, Susant Sahani sus...@redhat.com wrote: This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 19 src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 175 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 + src/network/networkd.h| 27 + 12 files changed, 334 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); +if (r = 0) +r = 0; +else +r = -1; + +kmod_module_unref(mod); +} + +kmod_module_unref_list(modlist); + +return r; +} diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 65cd0d7..28f53b9 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -24,6 +24,7 @@ #include netinet/ether.h #include netinet/in.h #include stdbool.h +#include libkmod.h #include udev.h #include condition-util.h @@ -65,3 +66,5 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, int net_parse_inaddr(const char *address, unsigned char *family, void *dst); int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); + +int load_module(struct kmod_ctx *ctx, const char *mod_name); diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c index 44ac5ec..96467a3 100644 --- a/src/libsystemd/sd-rtnl/rtnl-types.c +++ b/src/libsystemd/sd-rtnl/rtnl-types.c @@ -104,8 +104,8 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = { [IFLA_IPTUN_LINK]= { .type = NLA_U32 }, -[IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, -[IFLA_IPTUN_REMOTE] = { .type = NLA_U32 }, +[IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR }, +[IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR }, [IFLA_IPTUN_TTL] = { .type = NLA_U8 }, [IFLA_IPTUN_TOS] = { .type = NLA_U8 }, [IFLA_IPTUN_PMTUDISC]= { .type = NLA_U8 }, diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 63d253d..848eddd 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1207,7 +1207,9 @@ static int link_enter_enslave(Link *link) { link_save(link); -if (!link-network-bridge !link-network-bond +if (!link-network-bridge +!link-network-bond +
Re: [systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
On Mon, Apr 7, 2014 at 12:28 PM, Susant Sahani sus...@redhat.com wrote: +r = manager_init_kmod_ctx(m); Maybe just do manager-kmod_ctx = kmod_ctx_new(NULL, NULL); if (!manager-kmod_ctx) { r = -ENOMEM; etc... } and drop the wrapping function (see above). Any specific reason to drop it and do directly ? Either way is fine. I just suggested the wrapper is not really adding much once you drop the unref() from it. Cheers, Tom ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel
This patch enables basic ipip tunnel support. It works with kernel module ipip Example configuration file: ipip.netdev -- [NetDev] Name=ipip-tun Kind=ipip [Tunnel] Local=192.168.8.102 Remote=10.4.4.4 TTL=64 MTUBytes=1480 file: ipip.network -- [Match] Name=eth0 [Network] Tunnel=ipip-tun --- Makefile.am | 7 +- src/libsystemd-network/network-internal.c | 33 ++ src/libsystemd-network/network-internal.h | 3 + src/libsystemd/sd-rtnl/rtnl-types.c | 4 +- src/network/networkd-link.c | 25 - src/network/networkd-manager.c| 14 +++ src/network/networkd-netdev-gperf.gperf | 4 + src/network/networkd-netdev.c | 169 +- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c| 37 +++ src/network/networkd.c| 6 ++ src/network/networkd.h| 27 + 12 files changed, 323 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c51f6ae..60c7016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4144,8 +4144,8 @@ systemd_networkd_SOURCES = \ src/network/networkd.c systemd_networkd_LDADD = \ - libsystemd-networkd-core.la - + libsystemd-networkd-core.la \ + -lkmod noinst_LTLIBRARIES += \ libsystemd-networkd-core.la @@ -4189,7 +4189,8 @@ test_network_SOURCES = \ src/network/test-network.c test_network_LDADD = \ - libsystemd-networkd-core.la + libsystemd-networkd-core.la \ + -lkmod tests += \ test-network diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 3686267..5b41cdb 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -326,3 +326,36 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } + +int load_module(struct kmod_ctx *ctx, const char *mod_name) { +struct kmod_list *modlist = NULL, *l; +int r; + +assert(ctx); +assert(mod_name); + +r = kmod_module_new_from_lookup(ctx, mod_name, modlist); +if (r 0) +return r; + +if (!modlist) { +log_error(Failed to find module '%s', mod_name); +return -ENOENT; +} + +kmod_list_foreach(l, modlist) { +struct kmod_module *mod = kmod_module_get_module(l); + +r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); +if (r = 0) +r = 0; +else +r = -1; + +kmod_module_unref(mod); +} + +kmod_module_unref_list(modlist); + +return r; +} diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 65cd0d7..28f53b9 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -24,6 +24,7 @@ #include netinet/ether.h #include netinet/in.h #include stdbool.h +#include libkmod.h #include udev.h #include condition-util.h @@ -65,3 +66,5 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, int net_parse_inaddr(const char *address, unsigned char *family, void *dst); int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); + +int load_module(struct kmod_ctx *ctx, const char *mod_name); diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c index 44ac5ec..96467a3 100644 --- a/src/libsystemd/sd-rtnl/rtnl-types.c +++ b/src/libsystemd/sd-rtnl/rtnl-types.c @@ -104,8 +104,8 @@ static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { static const NLType rtnl_link_info_data_iptun_types[IFLA_IPTUN_MAX + 1] = { [IFLA_IPTUN_LINK]= { .type = NLA_U32 }, -[IFLA_IPTUN_LOCAL] = { .type = NLA_U32 }, -[IFLA_IPTUN_REMOTE] = { .type = NLA_U32 }, +[IFLA_IPTUN_LOCAL] = { .type = NLA_IN_ADDR }, +[IFLA_IPTUN_REMOTE] = { .type = NLA_IN_ADDR }, [IFLA_IPTUN_TTL] = { .type = NLA_U8 }, [IFLA_IPTUN_TOS] = { .type = NLA_U8 }, [IFLA_IPTUN_PMTUDISC]= { .type = NLA_U8 }, diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 63d253d..848eddd 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1207,7 +1207,9 @@ static int link_enter_enslave(Link *link) { link_save(link); -if (!link-network-bridge !link-network-bond +if (!link-network-bridge +!link-network-bond +!link-network-tunnel hashmap_isempty(link-network-vlans)