Path: blob/master/net/netlabel/netlabel_unlabeled.h
15109 views
/*1* NetLabel Unlabeled Support2*3* This file defines functions for dealing with unlabeled packets for the4* NetLabel system. The NetLabel system manages static and dynamic label5* mappings for network protocols such as CIPSO and RIPSO.6*7* Author: Paul Moore <[email protected]>8*9*/1011/*12* (c) Copyright Hewlett-Packard Development Company, L.P., 200613*14* This program is free software; you can redistribute it and/or modify15* it under the terms of the GNU General Public License as published by16* the Free Software Foundation; either version 2 of the License, or17* (at your option) any later version.18*19* This program is distributed in the hope that it will be useful,20* but WITHOUT ANY WARRANTY; without even the implied warranty of21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See22* the GNU General Public License for more details.23*24* You should have received a copy of the GNU General Public License25* along with this program; if not, write to the Free Software26* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA27*28*/2930#ifndef _NETLABEL_UNLABELED_H31#define _NETLABEL_UNLABELED_H3233#include <net/netlabel.h>3435/*36* The following NetLabel payloads are supported by the Unlabeled subsystem.37*38* o STATICADD39* This message is sent from an application to add a new static label for40* incoming unlabeled connections.41*42* Required attributes:43*44* NLBL_UNLABEL_A_IFACE45* NLBL_UNLABEL_A_SECCTX46*47* If IPv4 is specified the following attributes are required:48*49* NLBL_UNLABEL_A_IPV4ADDR50* NLBL_UNLABEL_A_IPV4MASK51*52* If IPv6 is specified the following attributes are required:53*54* NLBL_UNLABEL_A_IPV6ADDR55* NLBL_UNLABEL_A_IPV6MASK56*57* o STATICREMOVE58* This message is sent from an application to remove an existing static59* label for incoming unlabeled connections.60*61* Required attributes:62*63* NLBL_UNLABEL_A_IFACE64*65* If IPv4 is specified the following attributes are required:66*67* NLBL_UNLABEL_A_IPV4ADDR68* NLBL_UNLABEL_A_IPV4MASK69*70* If IPv6 is specified the following attributes are required:71*72* NLBL_UNLABEL_A_IPV6ADDR73* NLBL_UNLABEL_A_IPV6MASK74*75* o STATICLIST76* This message can be sent either from an application or by the kernel in77* response to an application generated STATICLIST message. When sent by an78* application there is no payload and the NLM_F_DUMP flag should be set.79* The kernel should response with a series of the following messages.80*81* Required attributes:82*83* NLBL_UNLABEL_A_IFACE84* NLBL_UNLABEL_A_SECCTX85*86* If IPv4 is specified the following attributes are required:87*88* NLBL_UNLABEL_A_IPV4ADDR89* NLBL_UNLABEL_A_IPV4MASK90*91* If IPv6 is specified the following attributes are required:92*93* NLBL_UNLABEL_A_IPV6ADDR94* NLBL_UNLABEL_A_IPV6MASK95*96* o STATICADDDEF97* This message is sent from an application to set the default static98* label for incoming unlabeled connections.99*100* Required attribute:101*102* NLBL_UNLABEL_A_SECCTX103*104* If IPv4 is specified the following attributes are required:105*106* NLBL_UNLABEL_A_IPV4ADDR107* NLBL_UNLABEL_A_IPV4MASK108*109* If IPv6 is specified the following attributes are required:110*111* NLBL_UNLABEL_A_IPV6ADDR112* NLBL_UNLABEL_A_IPV6MASK113*114* o STATICREMOVEDEF115* This message is sent from an application to remove the existing default116* static label for incoming unlabeled connections.117*118* If IPv4 is specified the following attributes are required:119*120* NLBL_UNLABEL_A_IPV4ADDR121* NLBL_UNLABEL_A_IPV4MASK122*123* If IPv6 is specified the following attributes are required:124*125* NLBL_UNLABEL_A_IPV6ADDR126* NLBL_UNLABEL_A_IPV6MASK127*128* o STATICLISTDEF129* This message can be sent either from an application or by the kernel in130* response to an application generated STATICLISTDEF message. When sent by131* an application there is no payload and the NLM_F_DUMP flag should be set.132* The kernel should response with the following message.133*134* Required attribute:135*136* NLBL_UNLABEL_A_SECCTX137*138* If IPv4 is specified the following attributes are required:139*140* NLBL_UNLABEL_A_IPV4ADDR141* NLBL_UNLABEL_A_IPV4MASK142*143* If IPv6 is specified the following attributes are required:144*145* NLBL_UNLABEL_A_IPV6ADDR146* NLBL_UNLABEL_A_IPV6MASK147*148* o ACCEPT149* This message is sent from an application to specify if the kernel should150* allow unlabled packets to pass if they do not match any of the static151* mappings defined in the unlabeled module.152*153* Required attributes:154*155* NLBL_UNLABEL_A_ACPTFLG156*157* o LIST158* This message can be sent either from an application or by the kernel in159* response to an application generated LIST message. When sent by an160* application there is no payload. The kernel should respond to a LIST161* message with a LIST message on success.162*163* Required attributes:164*165* NLBL_UNLABEL_A_ACPTFLG166*167*/168169/* NetLabel Unlabeled commands */170enum {171NLBL_UNLABEL_C_UNSPEC,172NLBL_UNLABEL_C_ACCEPT,173NLBL_UNLABEL_C_LIST,174NLBL_UNLABEL_C_STATICADD,175NLBL_UNLABEL_C_STATICREMOVE,176NLBL_UNLABEL_C_STATICLIST,177NLBL_UNLABEL_C_STATICADDDEF,178NLBL_UNLABEL_C_STATICREMOVEDEF,179NLBL_UNLABEL_C_STATICLISTDEF,180__NLBL_UNLABEL_C_MAX,181};182183/* NetLabel Unlabeled attributes */184enum {185NLBL_UNLABEL_A_UNSPEC,186NLBL_UNLABEL_A_ACPTFLG,187/* (NLA_U8)188* if true then unlabeled packets are allowed to pass, else unlabeled189* packets are rejected */190NLBL_UNLABEL_A_IPV6ADDR,191/* (NLA_BINARY, struct in6_addr)192* an IPv6 address */193NLBL_UNLABEL_A_IPV6MASK,194/* (NLA_BINARY, struct in6_addr)195* an IPv6 address mask */196NLBL_UNLABEL_A_IPV4ADDR,197/* (NLA_BINARY, struct in_addr)198* an IPv4 address */199NLBL_UNLABEL_A_IPV4MASK,200/* (NLA_BINARY, struct in_addr)201* and IPv4 address mask */202NLBL_UNLABEL_A_IFACE,203/* (NLA_NULL_STRING)204* network interface */205NLBL_UNLABEL_A_SECCTX,206/* (NLA_BINARY)207* a LSM specific security context */208__NLBL_UNLABEL_A_MAX,209};210#define NLBL_UNLABEL_A_MAX (__NLBL_UNLABEL_A_MAX - 1)211212/* NetLabel protocol functions */213int netlbl_unlabel_genl_init(void);214215/* Unlabeled connection hash table size */216/* XXX - currently this number is an uneducated guess */217#define NETLBL_UNLHSH_BITSIZE 7218219/* General Unlabeled init function */220int netlbl_unlabel_init(u32 size);221222/* Static/Fallback label management functions */223int netlbl_unlhsh_add(struct net *net,224const char *dev_name,225const void *addr,226const void *mask,227u32 addr_len,228u32 secid,229struct netlbl_audit *audit_info);230int netlbl_unlhsh_remove(struct net *net,231const char *dev_name,232const void *addr,233const void *mask,234u32 addr_len,235struct netlbl_audit *audit_info);236237/* Process Unlabeled incoming network packets */238int netlbl_unlabel_getattr(const struct sk_buff *skb,239u16 family,240struct netlbl_lsm_secattr *secattr);241242/* Set the default configuration to allow Unlabeled packets */243int netlbl_unlabel_defconf(void);244245#endif246247248