LCOV - code coverage report
Current view: top level - network/netdev - vxcan.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 32 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 <linux/can/vxcan.h>
       4             : 
       5             : #include "netdev/vxcan.h"
       6             : 
       7           0 : static int netdev_vxcan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
       8             :         VxCan *v;
       9             :         int r;
      10             : 
      11           0 :         assert(netdev);
      12           0 :         assert(!link);
      13           0 :         assert(m);
      14             : 
      15           0 :         v = VXCAN(netdev);
      16             : 
      17           0 :         assert(v);
      18             : 
      19           0 :         r = sd_netlink_message_open_container(m, VXCAN_INFO_PEER);
      20           0 :         if (r < 0)
      21           0 :                 return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m");
      22             : 
      23           0 :         if (v->ifname_peer) {
      24           0 :                 r = sd_netlink_message_append_string(m, IFLA_IFNAME, v->ifname_peer);
      25           0 :                 if (r < 0)
      26           0 :                         return log_error_errno(r, "Failed to add vxcan netlink interface peer name: %m");
      27             :         }
      28             : 
      29           0 :         r = sd_netlink_message_close_container(m);
      30           0 :         if (r < 0)
      31           0 :                 return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m");
      32             : 
      33           0 :         return r;
      34             : }
      35             : 
      36           0 : static int netdev_vxcan_verify(NetDev *netdev, const char *filename) {
      37             :         VxCan *v;
      38             : 
      39           0 :         assert(netdev);
      40           0 :         assert(filename);
      41             : 
      42           0 :         v = VXCAN(netdev);
      43             : 
      44           0 :         assert(v);
      45             : 
      46           0 :         if (!v->ifname_peer) {
      47           0 :                 log_warning("VxCan NetDev without peer name configured in %s. Ignoring", filename);
      48           0 :                 return -EINVAL;
      49             :         }
      50             : 
      51           0 :         return 0;
      52             : }
      53             : 
      54           0 : static void vxcan_done(NetDev *n) {
      55             :         VxCan *v;
      56             : 
      57           0 :         assert(n);
      58             : 
      59           0 :         v = VXCAN(n);
      60             : 
      61           0 :         assert(v);
      62             : 
      63           0 :         free(v->ifname_peer);
      64           0 : }
      65             : 
      66             : const NetDevVTable vxcan_vtable = {
      67             :         .object_size = sizeof(VxCan),
      68             :         .sections = "Match\0NetDev\0VXCAN\0",
      69             :         .done = vxcan_done,
      70             :         .fill_message_create = netdev_vxcan_fill_message_create,
      71             :         .create_type = NETDEV_CREATE_INDEPENDENT,
      72             :         .config_verify = netdev_vxcan_verify,
      73             :         .generate_mac = true,
      74             : };

Generated by: LCOV version 1.14