LCOV - code coverage report
Current view: top level - network/netdev - vlan.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 45 0.0 %
Date: 2019-08-22 15:41:25 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <errno.h>
       4             : #include <net/if.h>
       5             : #include <linux/if_vlan.h>
       6             : 
       7             : #include "netdev/vlan.h"
       8             : #include "vlan-util.h"
       9             : 
      10           0 : static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
      11           0 :         struct ifla_vlan_flags flags = {};
      12             :         VLan *v;
      13             :         int r;
      14             : 
      15           0 :         assert(netdev);
      16           0 :         assert(link);
      17           0 :         assert(req);
      18             : 
      19           0 :         v = VLAN(netdev);
      20             : 
      21           0 :         assert(v);
      22             : 
      23           0 :         r = sd_netlink_message_append_u16(req, IFLA_VLAN_ID, v->id);
      24           0 :         if (r < 0)
      25           0 :                 return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_ID attribute: %m");
      26             : 
      27           0 :         if (v->gvrp != -1) {
      28           0 :                 flags.mask |= VLAN_FLAG_GVRP;
      29           0 :                 SET_FLAG(flags.flags, VLAN_FLAG_GVRP, v->gvrp);
      30             :         }
      31             : 
      32           0 :         if (v->mvrp != -1) {
      33           0 :                 flags.mask |= VLAN_FLAG_MVRP;
      34           0 :                 SET_FLAG(flags.flags, VLAN_FLAG_MVRP, v->mvrp);
      35             :         }
      36             : 
      37           0 :         if (v->reorder_hdr != -1) {
      38           0 :                 flags.mask |= VLAN_FLAG_REORDER_HDR;
      39           0 :                 SET_FLAG(flags.flags, VLAN_FLAG_REORDER_HDR, v->reorder_hdr);
      40             :         }
      41             : 
      42           0 :         if (v->loose_binding != -1) {
      43           0 :                 flags.mask |= VLAN_FLAG_LOOSE_BINDING;
      44           0 :                 SET_FLAG(flags.flags, VLAN_FLAG_LOOSE_BINDING, v->loose_binding);
      45             :         }
      46             : 
      47           0 :         r = sd_netlink_message_append_data(req, IFLA_VLAN_FLAGS, &flags, sizeof(struct ifla_vlan_flags));
      48           0 :         if (r < 0)
      49           0 :                 return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_FLAGS attribute: %m");
      50             : 
      51           0 :         return 0;
      52             : }
      53             : 
      54           0 : static int netdev_vlan_verify(NetDev *netdev, const char *filename) {
      55             :         VLan *v;
      56             : 
      57           0 :         assert(netdev);
      58           0 :         assert(filename);
      59             : 
      60           0 :         v = VLAN(netdev);
      61             : 
      62           0 :         assert(v);
      63             : 
      64           0 :         if (v->id == VLANID_INVALID) {
      65           0 :                 log_warning("VLAN without valid Id (%"PRIu16") configured in %s.", v->id, filename);
      66           0 :                 return -EINVAL;
      67             :         }
      68             : 
      69           0 :         return 0;
      70             : }
      71             : 
      72           0 : static void vlan_init(NetDev *netdev) {
      73           0 :         VLan *v = VLAN(netdev);
      74             : 
      75           0 :         assert(netdev);
      76           0 :         assert(v);
      77             : 
      78           0 :         v->id = VLANID_INVALID;
      79           0 :         v->gvrp = -1;
      80           0 :         v->mvrp = -1;
      81           0 :         v->loose_binding = -1;
      82           0 :         v->reorder_hdr = -1;
      83           0 : }
      84             : 
      85             : const NetDevVTable vlan_vtable = {
      86             :         .object_size = sizeof(VLan),
      87             :         .init = vlan_init,
      88             :         .sections = "Match\0NetDev\0VLAN\0",
      89             :         .fill_message_create = netdev_vlan_fill_message_create,
      90             :         .create_type = NETDEV_CREATE_STACKED,
      91             :         .config_verify = netdev_vlan_verify,
      92             : };

Generated by: LCOV version 1.14