[systemd-devel] [PATCH 1/1] networkd: Introduce ipip tunnel

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sat Apr 12 11:04:43 PDT 2014


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


More information about the systemd-devel mailing list