/*
* NetLabel Unlabeled Support
*
* This file defines functions for dealing with unlabeled packets for the
* NetLabel system. The NetLabel system manages static and dynamic label
* mappings for network protocols such as CIPSO and RIPSO.
*
* Author: Paul Moore <paul.moore@hp.com>
*
*/
/*
* (c) Copyright Hewlett-Packard Development Company, L.P., 2006 - 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <linux/types.h>
#include <linux/rcupdate.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/socket.h>
#include <linux/string.h>
#include <linux/skbuff.h>
#include <linux/audit.h>
#include <linux/in.h>
#include <linux/in6.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/notifier.h>
#include <linux/netdevice.h>
#include <linux/security.h>
#include <net/sock.h>
#include <net/netlink.h>
#include <net/genetlink.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <net/net_namespace.h>
#include <net/netlabel.h>
#include <asm/bug.h>
#include <asm/atomic.h>
#include "netlabel_user.h"
#include "netlabel_addrlist.h"
#include "netlabel_domainhash.h"
#include "netlabel_unlabeled.h"
#include "netlabel_mgmt.h"
/* NOTE: at present we always use init's network namespace since we don't
* presently support different namespaces even though the majority of
* the functions in this file are "namespace safe" */
/* The unlabeled connection hash table which we use to map network interfaces
* and addresses of unlabeled packets to a user specified secid value for the
* LSM. The hash table is used to lookup the network interface entry
* (struct netlbl_unlhsh_iface) and then the interface entry is used to
* lookup an IP address match from an ordered list. If a network interface
* match can not be found in the hash table then the default entry
* (netlbl_unlhsh_def) is used. The IP address entry list
* (struct netlbl_unlhsh_addr) is ordered such that the entries with a
* larger netmask come first.
*/
struct netlbl_unlhsh_tbl {
struct list_head *tbl;
u32 size;
};
#define netlbl_unlhsh_addr4_entry(iter) \
container_of(iter, struct netlbl_unlhsh_addr4, list)
struct netlbl_unlhsh_addr4 {
u32 secid;
struct netlbl_af4list list;
struct rcu_head rcu;
};
#define netlbl_unlhsh_addr6_entry(iter) \
container_of(iter, struct netlbl_unlhsh_addr6, list)
struct netlbl_unlhsh_addr6 {
u32 secid;
struct netlbl_af6list list;
struct rcu_head rcu;
};
struct netlbl_unlhsh_iface {
int ifindex;
struct list_head addr4_list;
struct list_head addr6_list;
u32 valid;
struct list_head list;
struct rcu_head rcu;
};
/* Argument struct for netlbl_unlhsh_walk() */
struct netlbl_unlhsh_walk_arg {
struct netlink_callback *nl_cb;
struct sk_buff *skb;
u32 seq;
};
/* Unlabeled connection hash table */
/* updates should be so rare that having one spinlock fo
|