LCOV - code coverage report
Current view: top level - network - networkd-netdev-macvlan.c (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 1 23 4.3 %
Date: 2015-07-29 18:47:03 Functions: 2 5 40.0 %

          Line data    Source code
       1             : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
       2             : 
       3             : /***
       4             :   This file is part of systemd.
       5             : 
       6             :   Copyright 2013 Tom Gundersen <teg@jklm.no>
       7             : 
       8             :   systemd is free software; you can redistribute it and/or modify it
       9             :   under the terms of the GNU Lesser General Public License as published by
      10             :   the Free Software Foundation; either version 2.1 of the License, or
      11             :   (at your option) any later version.
      12             : 
      13             :   systemd is distributed in the hope that it will be useful, but
      14             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      16             :   Lesser General Public License for more details.
      17             : 
      18             :   You should have received a copy of the GNU Lesser General Public License
      19             :   along with systemd; If not, see <http://www.gnu.org/licenses/>.
      20             : ***/
      21             : 
      22             : #include <net/if.h>
      23             : 
      24             : #include "networkd-netdev-macvlan.h"
      25             : #include "conf-parser.h"
      26             : 
      27             : static const char* const macvlan_mode_table[_NETDEV_MACVLAN_MODE_MAX] = {
      28             :         [NETDEV_MACVLAN_MODE_PRIVATE] = "private",
      29             :         [NETDEV_MACVLAN_MODE_VEPA] = "vepa",
      30             :         [NETDEV_MACVLAN_MODE_BRIDGE] = "bridge",
      31             :         [NETDEV_MACVLAN_MODE_PASSTHRU] = "passthru",
      32             : };
      33             : 
      34          22 : DEFINE_STRING_TABLE_LOOKUP(macvlan_mode, MacVlanMode);
      35           0 : DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode");
      36             : 
      37           0 : static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
      38             :         MacVlan *m;
      39             :         int r;
      40             : 
      41           0 :         assert(netdev);
      42           0 :         assert(link);
      43           0 :         assert(netdev->ifname);
      44             : 
      45           0 :         if (netdev->kind == NETDEV_KIND_MACVLAN)
      46           0 :                 m = MACVLAN(netdev);
      47             :         else
      48           0 :                 m = MACVTAP(netdev);
      49             : 
      50           0 :         assert(m);
      51             : 
      52           0 :         if (m->mode != _NETDEV_MACVLAN_MODE_INVALID) {
      53           0 :                 r = sd_netlink_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode);
      54           0 :                 if (r < 0)
      55           0 :                         return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_MODE attribute: %m");
      56             :         }
      57             : 
      58           0 :         return 0;
      59             : }
      60             : 
      61           0 : static void macvlan_init(NetDev *n) {
      62             :         MacVlan *m;
      63             : 
      64           0 :         assert(n);
      65             : 
      66           0 :         if (n->kind == NETDEV_KIND_MACVLAN)
      67           0 :                 m = MACVLAN(n);
      68             :         else
      69           0 :                 m = MACVTAP(n);
      70             : 
      71           0 :         assert(m);
      72             : 
      73           0 :         m->mode = _NETDEV_MACVLAN_MODE_INVALID;
      74           0 : }
      75             : 
      76             : const NetDevVTable macvtap_vtable = {
      77             :         .object_size = sizeof(MacVlan),
      78             :         .init = macvlan_init,
      79             :         .sections = "Match\0NetDev\0MACVTAP\0",
      80             :         .fill_message_create = netdev_macvlan_fill_message_create,
      81             :         .create_type = NETDEV_CREATE_STACKED,
      82             : };
      83             : 
      84             : const NetDevVTable macvlan_vtable = {
      85             :         .object_size = sizeof(MacVlan),
      86             :         .init = macvlan_init,
      87             :         .sections = "Match\0NetDev\0MACVLAN\0",
      88             :         .fill_message_create = netdev_macvlan_fill_message_create,
      89             :         .create_type = NETDEV_CREATE_STACKED,
      90             : };

Generated by: LCOV version 1.11