chiark / gitweb /
networkd: introduce gretap
authorSusant Sahani <susant@redhat.com>
Sat, 20 Dec 2014 08:05:06 +0000 (13:35 +0530)
committerTom Gundersen <teg@jklm.no>
Thu, 22 Jan 2015 20:29:41 +0000 (21:29 +0100)
This patch introdeces gretap to networkd

man/systemd.netdev.xml
src/libsystemd/sd-rtnl/rtnl-types.c
src/libsystemd/sd-rtnl/rtnl-types.h
src/network/networkd-netdev-tunnel.c
src/network/networkd-netdev-tunnel.h
src/network/networkd-netdev.c
src/network/networkd-netdev.h
src/network/networkd-network.c

index 03b0940..ca50558 100644 (file)
                                                 <literal>macvlan</literal>,
                                                 <literal>ipvlan</literal>, <literal>vxlan</literal>,
                                                 <literal>ipip</literal>, <literal>gre</literal>,
-                                                <literal>sit</literal>, <literal>vti</literal>,
-                                                <literal>veth</literal>, <literal>tun</literal>,
-                                                <literal>tap</literal> and <literal>dummy</literal>
+                                                <literal>gretap</literal>, <literal>sit</literal>,
+                                                <literal>vti</literal>, <literal>veth</literal>,
+                                                <literal>tun</literal>, <literal>tap</literal> and
+                                                <literal>dummy</literal>
                                                 are supported. This option is compulsory.</para>
                                         </listitem>
                                 </varlistentry>
                 <title>[Tunnel] Section Options</title>
 
                         <para>The <literal>[Tunnel]</literal> section only applies for netdevs of kind
-                        <literal>ipip</literal>, <literal>sit</literal>, <literal>gre</literal> and
-                        <literal>vti</literal> and accepts the following keys:</para>
+                        <literal>ipip</literal>, <literal>sit</literal>, <literal>gre</literal>, <literal>gretap</literal>,
+                        and <literal>vti</literal> and accepts the following keys:</para>
 
                         <variablelist class='network-directives'>
                                 <varlistentry>
index b0bd661..97b3cee 100644 (file)
@@ -165,6 +165,7 @@ static const char* const nl_union_link_info_data_table[_NL_UNION_LINK_INFO_DATA_
         [NL_UNION_LINK_INFO_DATA_VXLAN] = "vxlan",
         [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = "ipip",
         [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = "gre",
+        [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = "gretap",
         [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = "sit",
         [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = "vti",
 };
@@ -190,6 +191,8 @@ static const NLTypeSystem rtnl_link_info_data_type_systems[_NL_UNION_LINK_INFO_D
                                                   .types = rtnl_link_info_data_iptun_types },
         [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] =  { .max = ELEMENTSOF(rtnl_link_info_data_ipgre_types) - 1,
                                                     .types = rtnl_link_info_data_ipgre_types },
+        [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] =  { .max = ELEMENTSOF(rtnl_link_info_data_ipgre_types) - 1,
+                                                    .types = rtnl_link_info_data_ipgre_types },
         [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] =  { .max = ELEMENTSOF(rtnl_link_info_data_iptun_types) - 1,
                                                   .types = rtnl_link_info_data_iptun_types },
         [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] =  { .max = ELEMENTSOF(rtnl_link_info_data_ipvti_types) - 1,
index 1bb17a4..aacea19 100644 (file)
@@ -75,6 +75,7 @@ typedef enum NLUnionLinkInfoData {
         NL_UNION_LINK_INFO_DATA_VXLAN,
         NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL,
         NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL,
+        NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL,
         NL_UNION_LINK_INFO_DATA_SIT_TUNNEL,
         NL_UNION_LINK_INFO_DATA_VTI_TUNNEL,
         _NL_UNION_LINK_INFO_DATA_MAX,
index 31d3464..fde08fb 100644 (file)
@@ -140,14 +140,20 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
 }
 
 static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *m) {
-        Tunnel *t = GRE(netdev);
+        Tunnel *t;
         int r;
 
         assert(netdev);
-        assert(link);
-        assert(m);
+
+        if (netdev->kind == NETDEV_KIND_GRE)
+                 t = GRE(netdev);
+        else
+                 t = GRETAP(netdev);
+
         assert(t);
         assert(t->family == AF_INET);
+        assert(link);
+        assert(m);
 
         r = sd_rtnl_message_append_u32(m, IFLA_GRE_LINK, link->ifindex);
         if (r < 0) {
@@ -253,6 +259,9 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
         case NETDEV_KIND_GRE:
                 t = GRE(netdev);
                 break;
+        case NETDEV_KIND_GRETAP:
+                t = GRETAP(netdev);
+                break;
         case NETDEV_KIND_VTI:
                 t = VTI(netdev);
                 break;
@@ -339,9 +348,15 @@ static void vti_init(NetDev *n) {
 }
 
 static void gre_init(NetDev *n) {
-        Tunnel *t = GRE(n);
+        Tunnel *t;
 
         assert(n);
+
+        if (n->kind == NETDEV_KIND_GRE)
+                t = GRE(n);
+        else
+                t = GRETAP(n);
+
         assert(t);
 
         t->pmtudisc = true;
@@ -382,3 +397,12 @@ const NetDevVTable gre_vtable = {
         .create_type = NETDEV_CREATE_STACKED,
         .config_verify = netdev_tunnel_verify,
 };
+
+const NetDevVTable gretap_vtable = {
+        .object_size = sizeof(Tunnel),
+        .init = gre_init,
+        .sections = "Match\0NetDev\0Tunnel\0",
+        .fill_message_create = netdev_gre_fill_message_create,
+        .create_type = NETDEV_CREATE_STACKED,
+        .config_verify = netdev_tunnel_verify,
+};
index 000a646..b6f6c9d 100644 (file)
@@ -41,3 +41,4 @@ extern const NetDevVTable ipip_vtable;
 extern const NetDevVTable sit_vtable;
 extern const NetDevVTable vti_vtable;
 extern const NetDevVTable gre_vtable;
+extern const NetDevVTable gretap_vtable;
index 89efc88..4e1fb43 100644 (file)
@@ -39,6 +39,7 @@ const NetDevVTable * const netdev_vtable[_NETDEV_KIND_MAX] = {
         [NETDEV_KIND_VXLAN] = &vxlan_vtable,
         [NETDEV_KIND_IPIP] = &ipip_vtable,
         [NETDEV_KIND_GRE] = &gre_vtable,
+        [NETDEV_KIND_GRETAP] = &gretap_vtable,
         [NETDEV_KIND_SIT] = &sit_vtable,
         [NETDEV_KIND_VTI] = &vti_vtable,
         [NETDEV_KIND_VETH] = &veth_vtable,
@@ -56,6 +57,7 @@ static const char* const netdev_kind_table[_NETDEV_KIND_MAX] = {
         [NETDEV_KIND_VXLAN] = "vxlan",
         [NETDEV_KIND_IPIP] = "ipip",
         [NETDEV_KIND_GRE] = "gre",
+        [NETDEV_KIND_GRETAP] = "gretap",
         [NETDEV_KIND_SIT] = "sit",
         [NETDEV_KIND_VETH] = "veth",
         [NETDEV_KIND_VTI] = "vti",
index 1b311c6..3c44795 100644 (file)
@@ -47,6 +47,7 @@ typedef enum NetDevKind {
         NETDEV_KIND_VXLAN,
         NETDEV_KIND_IPIP,
         NETDEV_KIND_GRE,
+        NETDEV_KIND_GRETAP,
         NETDEV_KIND_SIT,
         NETDEV_KIND_VETH,
         NETDEV_KIND_VTI,
@@ -163,6 +164,7 @@ DEFINE_CAST(IPVLAN, IPVlan);
 DEFINE_CAST(VXLAN, VxLan);
 DEFINE_CAST(IPIP, Tunnel);
 DEFINE_CAST(GRE, Tunnel);
+DEFINE_CAST(GRETAP, Tunnel);
 DEFINE_CAST(SIT, Tunnel);
 DEFINE_CAST(VTI, Tunnel);
 DEFINE_CAST(VETH, Veth);
index b824526..2b555ef 100644 (file)
@@ -452,6 +452,7 @@ int config_parse_tunnel(const char *unit,
         if (netdev->kind != NETDEV_KIND_IPIP &&
             netdev->kind != NETDEV_KIND_SIT &&
             netdev->kind != NETDEV_KIND_GRE &&
+            netdev->kind != NETDEV_KIND_GRETAP &&
             netdev->kind != NETDEV_KIND_VTI) {
                 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
                            "NetDev is not a tunnel, ignoring assignment: %s", rvalue);