/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* NetLabel Unlabeled Support3*4* This file defines functions for dealing with unlabeled packets for the5* NetLabel system. The NetLabel system manages static and dynamic label6* mappings for network protocols such as CIPSO and RIPSO.7*8* Author: Paul Moore <[email protected]>9*/1011/*12* (c) Copyright Hewlett-Packard Development Company, L.P., 200613*/1415#ifndef _NETLABEL_UNLABELED_H16#define _NETLABEL_UNLABELED_H1718#include <net/netlabel.h>1920/*21* The following NetLabel payloads are supported by the Unlabeled subsystem.22*23* o STATICADD24* This message is sent from an application to add a new static label for25* incoming unlabeled connections.26*27* Required attributes:28*29* NLBL_UNLABEL_A_IFACE30* NLBL_UNLABEL_A_SECCTX31*32* If IPv4 is specified the following attributes are required:33*34* NLBL_UNLABEL_A_IPV4ADDR35* NLBL_UNLABEL_A_IPV4MASK36*37* If IPv6 is specified the following attributes are required:38*39* NLBL_UNLABEL_A_IPV6ADDR40* NLBL_UNLABEL_A_IPV6MASK41*42* o STATICREMOVE43* This message is sent from an application to remove an existing static44* label for incoming unlabeled connections.45*46* Required attributes:47*48* NLBL_UNLABEL_A_IFACE49*50* If IPv4 is specified the following attributes are required:51*52* NLBL_UNLABEL_A_IPV4ADDR53* NLBL_UNLABEL_A_IPV4MASK54*55* If IPv6 is specified the following attributes are required:56*57* NLBL_UNLABEL_A_IPV6ADDR58* NLBL_UNLABEL_A_IPV6MASK59*60* o STATICLIST61* This message can be sent either from an application or by the kernel in62* response to an application generated STATICLIST message. When sent by an63* application there is no payload and the NLM_F_DUMP flag should be set.64* The kernel should response with a series of the following messages.65*66* Required attributes:67*68* NLBL_UNLABEL_A_IFACE69* NLBL_UNLABEL_A_SECCTX70*71* If IPv4 is specified the following attributes are required:72*73* NLBL_UNLABEL_A_IPV4ADDR74* NLBL_UNLABEL_A_IPV4MASK75*76* If IPv6 is specified the following attributes are required:77*78* NLBL_UNLABEL_A_IPV6ADDR79* NLBL_UNLABEL_A_IPV6MASK80*81* o STATICADDDEF82* This message is sent from an application to set the default static83* label for incoming unlabeled connections.84*85* Required attribute:86*87* NLBL_UNLABEL_A_SECCTX88*89* If IPv4 is specified the following attributes are required:90*91* NLBL_UNLABEL_A_IPV4ADDR92* NLBL_UNLABEL_A_IPV4MASK93*94* If IPv6 is specified the following attributes are required:95*96* NLBL_UNLABEL_A_IPV6ADDR97* NLBL_UNLABEL_A_IPV6MASK98*99* o STATICREMOVEDEF100* This message is sent from an application to remove the existing default101* static label for incoming unlabeled connections.102*103* If IPv4 is specified the following attributes are required:104*105* NLBL_UNLABEL_A_IPV4ADDR106* NLBL_UNLABEL_A_IPV4MASK107*108* If IPv6 is specified the following attributes are required:109*110* NLBL_UNLABEL_A_IPV6ADDR111* NLBL_UNLABEL_A_IPV6MASK112*113* o STATICLISTDEF114* This message can be sent either from an application or by the kernel in115* response to an application generated STATICLISTDEF message. When sent by116* an application there is no payload and the NLM_F_DUMP flag should be set.117* The kernel should response with the following message.118*119* Required attribute:120*121* NLBL_UNLABEL_A_SECCTX122*123* If IPv4 is specified the following attributes are required:124*125* NLBL_UNLABEL_A_IPV4ADDR126* NLBL_UNLABEL_A_IPV4MASK127*128* If IPv6 is specified the following attributes are required:129*130* NLBL_UNLABEL_A_IPV6ADDR131* NLBL_UNLABEL_A_IPV6MASK132*133* o ACCEPT134* This message is sent from an application to specify if the kernel should135* allow unlabled packets to pass if they do not match any of the static136* mappings defined in the unlabeled module.137*138* Required attributes:139*140* NLBL_UNLABEL_A_ACPTFLG141*142* o LIST143* This message can be sent either from an application or by the kernel in144* response to an application generated LIST message. When sent by an145* application there is no payload. The kernel should respond to a LIST146* message with a LIST message on success.147*148* Required attributes:149*150* NLBL_UNLABEL_A_ACPTFLG151*152*/153154/* NetLabel Unlabeled commands */155enum {156NLBL_UNLABEL_C_UNSPEC,157NLBL_UNLABEL_C_ACCEPT,158NLBL_UNLABEL_C_LIST,159NLBL_UNLABEL_C_STATICADD,160NLBL_UNLABEL_C_STATICREMOVE,161NLBL_UNLABEL_C_STATICLIST,162NLBL_UNLABEL_C_STATICADDDEF,163NLBL_UNLABEL_C_STATICREMOVEDEF,164NLBL_UNLABEL_C_STATICLISTDEF,165__NLBL_UNLABEL_C_MAX,166};167168/* NetLabel Unlabeled attributes */169enum {170NLBL_UNLABEL_A_UNSPEC,171NLBL_UNLABEL_A_ACPTFLG,172/* (NLA_U8)173* if true then unlabeled packets are allowed to pass, else unlabeled174* packets are rejected */175NLBL_UNLABEL_A_IPV6ADDR,176/* (NLA_BINARY, struct in6_addr)177* an IPv6 address */178NLBL_UNLABEL_A_IPV6MASK,179/* (NLA_BINARY, struct in6_addr)180* an IPv6 address mask */181NLBL_UNLABEL_A_IPV4ADDR,182/* (NLA_BINARY, struct in_addr)183* an IPv4 address */184NLBL_UNLABEL_A_IPV4MASK,185/* (NLA_BINARY, struct in_addr)186* and IPv4 address mask */187NLBL_UNLABEL_A_IFACE,188/* (NLA_NULL_STRING)189* network interface */190NLBL_UNLABEL_A_SECCTX,191/* (NLA_BINARY)192* a LSM specific security context */193__NLBL_UNLABEL_A_MAX,194};195#define NLBL_UNLABEL_A_MAX (__NLBL_UNLABEL_A_MAX - 1)196197/* NetLabel protocol functions */198int netlbl_unlabel_genl_init(void);199200/* Unlabeled connection hash table size */201/* XXX - currently this number is an uneducated guess */202#define NETLBL_UNLHSH_BITSIZE 7203204/* General Unlabeled init function */205int netlbl_unlabel_init(u32 size);206207/* Static/Fallback label management functions */208int netlbl_unlhsh_add(struct net *net,209const char *dev_name,210const void *addr,211const void *mask,212u32 addr_len,213u32 secid,214struct netlbl_audit *audit_info);215int netlbl_unlhsh_remove(struct net *net,216const char *dev_name,217const void *addr,218const void *mask,219u32 addr_len,220struct netlbl_audit *audit_info);221222/* Process Unlabeled incoming network packets */223int netlbl_unlabel_getattr(const struct sk_buff *skb,224u16 family,225struct netlbl_lsm_secattr *secattr);226227/* Set the default configuration to allow Unlabeled packets */228int netlbl_unlabel_defconf(void);229230#endif231232233