]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: merge ipip_init() and sit_init()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 31 Mar 2019 13:02:37 +0000 (22:02 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Apr 2019 18:07:08 +0000 (03:07 +0900)
src/network/netdev/tunnel.c

index eae31ff0a822fd783022d7e8b64639d309b774d0..719b5e4add508b9bd591c8ef52172ccb99b4d2da 100644 (file)
@@ -683,20 +683,22 @@ int config_parse_6rd_prefix(const char* unit,
         return 0;
 }
 
-static void ipip_init(NetDev *n) {
-        Tunnel *t = IPIP(n);
+static void ipip_sit_init(NetDev *n) {
+        Tunnel *t;
 
         assert(n);
-        assert(t);
-
-        t->pmtudisc = true;
-        t->fou_encap_type = FOU_ENCAP_DIRECT;
-}
 
-static void sit_init(NetDev *n) {
-        Tunnel *t = SIT(n);
+        switch (n->kind) {
+        case NETDEV_KIND_IPIP:
+                t = IPIP(n);
+                break;
+        case NETDEV_KIND_SIT:
+                t = SIT(n);
+                break;
+        default:
+                assert_not_reached("invalid netdev kind");
+        }
 
-        assert(n);
         assert(t);
 
         t->pmtudisc = true;
@@ -775,7 +777,7 @@ static void ip6tnl_init(NetDev *n) {
 
 const NetDevVTable ipip_vtable = {
         .object_size = sizeof(Tunnel),
-        .init = ipip_init,
+        .init = ipip_sit_init,
         .sections = "Match\0NetDev\0Tunnel\0",
         .fill_message_create = netdev_ipip_sit_fill_message_create,
         .create_type = NETDEV_CREATE_STACKED,
@@ -784,7 +786,7 @@ const NetDevVTable ipip_vtable = {
 
 const NetDevVTable sit_vtable = {
         .object_size = sizeof(Tunnel),
-        .init = sit_init,
+        .init = ipip_sit_init,
         .sections = "Match\0NetDev\0Tunnel\0",
         .fill_message_create = netdev_ipip_sit_fill_message_create,
         .create_type = NETDEV_CREATE_STACKED,