X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=datapath%2Fbrc_procfs.c;h=36659482a0232cbf6d608c3397c69d5ac4215055;hb=404c169247b1c3ac2ebad887f0421478a6cef924;hp=ae4a4f50f87c4cc97878dc58198e4e2a2178119f;hpb=34e63086edddcae06d7c1a4fa84fec0861e50758;p=openvswitch diff --git a/datapath/brc_procfs.c b/datapath/brc_procfs.c index ae4a4f50..36659482 100644 --- a/datapath/brc_procfs.c +++ b/datapath/brc_procfs.c @@ -1,17 +1,20 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010, 2011 Nicira Networks. * Distributed under the terms of the GNU GPL version 2. * * Significant portions of this file may be copied from parts of the Linux * kernel, by Linus Torvalds and others. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include #include #include #include +#include "brc_procfs.h" #include "openvswitch/brcompat-netlink.h" /* This code implements a Generic Netlink command BRC_GENL_C_SET_PROC that can @@ -49,7 +52,7 @@ static struct file_operations brc_fops = { static struct proc_dir_entry *proc_vlan_dir; static struct proc_dir_entry *proc_bonding_dir; -struct proc_dir_entry *brc_lookup_entry(struct proc_dir_entry *de, const char *name) +static struct proc_dir_entry *brc_lookup_entry(struct proc_dir_entry *de, const char *name) { int namelen = strlen(name); for (de = de->subdir; de; de = de->next) { @@ -68,9 +71,9 @@ static struct proc_dir_entry *brc_open_dir(const char *dir_name, if (!*dirp) { struct proc_dir_entry *dir; if (brc_lookup_entry(parent, dir_name)) { - printk(KERN_WARNING "%s proc directory exists, can't " - "simulate--probably its real module is " - "loaded\n", dir_name); + pr_warn("%s proc directory exists, can't simulate--" + "probably its real module is loaded\n", + dir_name); return NULL; } dir = *dirp = proc_mkdir(dir_name, parent); @@ -78,13 +81,6 @@ static struct proc_dir_entry *brc_open_dir(const char *dir_name, return *dirp; } -/* Maximum length of the BRC_GENL_A_PROC_DIR and BRC_GENL_A_PROC_NAME strings. - * If we could depend on supporting NLA_NUL_STRING and the .len member in - * Generic Netlink policy, then we could just put this in brc_genl_policy (and - * simplify brc_genl_set_proc() below too), but upstream 2.6.18 does not have - * either. */ -#define BRC_NAME_LEN_MAX 32 - int brc_genl_set_proc(struct sk_buff *skb, struct genl_info *info) { struct proc_dir_entry *dir, *entry; @@ -92,18 +88,15 @@ int brc_genl_set_proc(struct sk_buff *skb, struct genl_info *info) char *data; if (!info->attrs[BRC_GENL_A_PROC_DIR] || - VERIFY_NUL_STRING(info->attrs[BRC_GENL_A_PROC_DIR]) || + VERIFY_NUL_STRING(info->attrs[BRC_GENL_A_PROC_DIR], BRC_NAME_LEN_MAX) || !info->attrs[BRC_GENL_A_PROC_NAME] || - VERIFY_NUL_STRING(info->attrs[BRC_GENL_A_PROC_NAME]) || + VERIFY_NUL_STRING(info->attrs[BRC_GENL_A_PROC_NAME], BRC_NAME_LEN_MAX) || (info->attrs[BRC_GENL_A_PROC_DATA] && - VERIFY_NUL_STRING(info->attrs[BRC_GENL_A_PROC_DATA]))) + VERIFY_NUL_STRING(info->attrs[BRC_GENL_A_PROC_DATA], INT_MAX))) return -EINVAL; dir_name = nla_data(info->attrs[BRC_GENL_A_PROC_DIR]); name = nla_data(info->attrs[BRC_GENL_A_PROC_NAME]); - if (strlen(dir_name) > BRC_NAME_LEN_MAX || - strlen(name) > BRC_NAME_LEN_MAX) - return -EINVAL; if (!strcmp(dir_name, "net/vlan")) dir = brc_open_dir("vlan", proc_net, &proc_vlan_dir); @@ -168,7 +161,7 @@ static void kill_proc_dir(const char *dir_name, if (!e) break; - if (e->namelen >= sizeof name) { + if (e->namelen >= sizeof(name)) { /* Can't happen: we prevent adding names this long by * limiting the BRC_GENL_A_PROC_NAME string to * BRC_NAME_LEN_MAX bytes. */