LCOV - code coverage report
Current view: top level - net/ipv4 - sysfs_net_ipv4.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 13 0.0 %
Date: 2014-04-07 Functions: 0 13 0.0 %
Branches: 0 28 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * net/ipv4/sysfs_net_ipv4.c
       3                 :            :  *
       4                 :            :  * sysfs-based networking knobs (so we can, unlike with sysctl, control perms)
       5                 :            :  *
       6                 :            :  * Copyright (C) 2008 Google, Inc.
       7                 :            :  *
       8                 :            :  * Robert Love <rlove@google.com>
       9                 :            :  *
      10                 :            :  * This software is licensed under the terms of the GNU General Public
      11                 :            :  * License version 2, as published by the Free Software Foundation, and
      12                 :            :  * may be copied, distributed, and modified under those terms.
      13                 :            :  *
      14                 :            :  * This program is distributed in the hope that it will be useful,
      15                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17                 :            :  * GNU General Public License for more details.
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <linux/kobject.h>
      21                 :            : #include <linux/string.h>
      22                 :            : #include <linux/sysfs.h>
      23                 :            : #include <linux/init.h>
      24                 :            : #include <net/tcp.h>
      25                 :            : 
      26                 :            : #define CREATE_IPV4_FILE(_name, _var) \
      27                 :            : static ssize_t _name##_show(struct kobject *kobj, \
      28                 :            :                             struct kobj_attribute *attr, char *buf) \
      29                 :            : { \
      30                 :            :         return sprintf(buf, "%d\n", _var); \
      31                 :            : } \
      32                 :            : static ssize_t _name##_store(struct kobject *kobj, \
      33                 :            :                              struct kobj_attribute *attr, \
      34                 :            :                              const char *buf, size_t count) \
      35                 :            : { \
      36                 :            :         int val, ret; \
      37                 :            :         ret = sscanf(buf, "%d", &val); \
      38                 :            :         if (ret != 1) \
      39                 :            :                 return -EINVAL; \
      40                 :            :         if (val < 0) \
      41                 :            :                 return -EINVAL; \
      42                 :            :         _var = val; \
      43                 :            :         return count; \
      44                 :            : } \
      45                 :            : static struct kobj_attribute _name##_attr = \
      46                 :            :         __ATTR(_name, 0644, _name##_show, _name##_store)
      47                 :            : 
      48 [ #  # ][ #  # ]:          0 : CREATE_IPV4_FILE(tcp_wmem_min, sysctl_tcp_wmem[0]);
      49 [ #  # ][ #  # ]:          0 : CREATE_IPV4_FILE(tcp_wmem_def, sysctl_tcp_wmem[1]);
      50 [ #  # ][ #  # ]:          0 : CREATE_IPV4_FILE(tcp_wmem_max, sysctl_tcp_wmem[2]);
      51                 :            : 
      52 [ #  # ][ #  # ]:          0 : CREATE_IPV4_FILE(tcp_rmem_min, sysctl_tcp_rmem[0]);
      53 [ #  # ][ #  # ]:          0 : CREATE_IPV4_FILE(tcp_rmem_def, sysctl_tcp_rmem[1]);
      54 [ #  # ][ #  # ]:          0 : CREATE_IPV4_FILE(tcp_rmem_max, sysctl_tcp_rmem[2]);
      55                 :            : 
      56                 :            : static struct attribute *ipv4_attrs[] = {
      57                 :            :         &tcp_wmem_min_attr.attr,
      58                 :            :         &tcp_wmem_def_attr.attr,
      59                 :            :         &tcp_wmem_max_attr.attr,
      60                 :            :         &tcp_rmem_min_attr.attr,
      61                 :            :         &tcp_rmem_def_attr.attr,
      62                 :            :         &tcp_rmem_max_attr.attr,
      63                 :            :         NULL
      64                 :            : };
      65                 :            : 
      66                 :            : static struct attribute_group ipv4_attr_group = {
      67                 :            :         .attrs = ipv4_attrs,
      68                 :            : };
      69                 :            : 
      70                 :          0 : static __init int sysfs_ipv4_init(void)
      71                 :            : {
      72                 :            :         struct kobject *ipv4_kobject;
      73                 :            :         int ret;
      74                 :            : 
      75                 :          0 :         ipv4_kobject = kobject_create_and_add("ipv4", kernel_kobj);
      76         [ #  # ]:          0 :         if (!ipv4_kobject)
      77                 :            :                 return -ENOMEM;
      78                 :            : 
      79                 :          0 :         ret = sysfs_create_group(ipv4_kobject, &ipv4_attr_group);
      80         [ #  # ]:          0 :         if (ret) {
      81                 :          0 :                 kobject_put(ipv4_kobject);
      82                 :          0 :                 return ret;
      83                 :            :         }
      84                 :            : 
      85                 :            :         return 0;
      86                 :            : }
      87                 :            : 
      88                 :            : subsys_initcall(sysfs_ipv4_init);

Generated by: LCOV version 1.9