netlabel.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * NetLabel System
  3. *
  4. * The NetLabel system manages static and dynamic label mappings for network
  5. * protocols such as CIPSO and RIPSO.
  6. *
  7. * Author: Paul Moore <paul@paul-moore.com>
  8. *
  9. */
  10. /*
  11. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  21. * the GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. #ifndef _NETLABEL_H
  28. #define _NETLABEL_H
  29. #include <linux/types.h>
  30. #include <linux/slab.h>
  31. #include <linux/net.h>
  32. #include <linux/skbuff.h>
  33. #include <linux/in.h>
  34. #include <linux/in6.h>
  35. #include <net/netlink.h>
  36. #include <net/request_sock.h>
  37. #include <linux/atomic.h>
  38. struct cipso_v4_doi;
  39. struct calipso_doi;
  40. /*
  41. * NetLabel - A management interface for maintaining network packet label
  42. * mapping tables for explicit packet labling protocols.
  43. *
  44. * Network protocols such as CIPSO and RIPSO require a label translation layer
  45. * to convert the label on the packet into something meaningful on the host
  46. * machine. In the current Linux implementation these mapping tables live
  47. * inside the kernel; NetLabel provides a mechanism for user space applications
  48. * to manage these mapping tables.
  49. *
  50. * NetLabel makes use of the Generic NETLINK mechanism as a transport layer to
  51. * send messages between kernel and user space. The general format of a
  52. * NetLabel message is shown below:
  53. *
  54. * +-----------------+-------------------+--------- --- -- -
  55. * | struct nlmsghdr | struct genlmsghdr | payload
  56. * +-----------------+-------------------+--------- --- -- -
  57. *
  58. * The 'nlmsghdr' and 'genlmsghdr' structs should be dealt with like normal.
  59. * The payload is dependent on the subsystem specified in the
  60. * 'nlmsghdr->nlmsg_type' and should be defined below, supporting functions
  61. * should be defined in the corresponding net/netlabel/netlabel_<subsys>.h|c
  62. * file. All of the fields in the NetLabel payload are NETLINK attributes, see
  63. * the include/net/netlink.h file for more information on NETLINK attributes.
  64. *
  65. */
  66. /*
  67. * NetLabel NETLINK protocol
  68. */
  69. /* NetLabel NETLINK protocol version
  70. * 1: initial version
  71. * 2: added static labels for unlabeled connections
  72. * 3: network selectors added to the NetLabel/LSM domain mapping and the
  73. * CIPSO_V4_MAP_LOCAL CIPSO mapping was added
  74. */
  75. #define NETLBL_PROTO_VERSION 3
  76. /* NetLabel NETLINK types/families */
  77. #define NETLBL_NLTYPE_NONE 0
  78. #define NETLBL_NLTYPE_MGMT 1
  79. #define NETLBL_NLTYPE_MGMT_NAME "NLBL_MGMT"
  80. #define NETLBL_NLTYPE_RIPSO 2
  81. #define NETLBL_NLTYPE_RIPSO_NAME "NLBL_RIPSO"
  82. #define NETLBL_NLTYPE_CIPSOV4 3
  83. #define NETLBL_NLTYPE_CIPSOV4_NAME "NLBL_CIPSOv4"
  84. #define NETLBL_NLTYPE_CIPSOV6 4
  85. #define NETLBL_NLTYPE_CIPSOV6_NAME "NLBL_CIPSOv6"
  86. #define NETLBL_NLTYPE_UNLABELED 5
  87. #define NETLBL_NLTYPE_UNLABELED_NAME "NLBL_UNLBL"
  88. #define NETLBL_NLTYPE_ADDRSELECT 6
  89. #define NETLBL_NLTYPE_ADDRSELECT_NAME "NLBL_ADRSEL"
  90. #define NETLBL_NLTYPE_CALIPSO 7
  91. #define NETLBL_NLTYPE_CALIPSO_NAME "NLBL_CALIPSO"
  92. /*
  93. * NetLabel - Kernel API for accessing the network packet label mappings.
  94. *
  95. * The following functions are provided for use by other kernel modules,
  96. * specifically kernel LSM modules, to provide a consistent, transparent API
  97. * for dealing with explicit packet labeling protocols such as CIPSO and
  98. * RIPSO. The functions defined here are implemented in the
  99. * net/netlabel/netlabel_kapi.c file.
  100. *
  101. */
  102. /* NetLabel audit information */
  103. struct netlbl_audit {
  104. u32 secid;
  105. kuid_t loginuid;
  106. unsigned int sessionid;
  107. };
  108. /*
  109. * LSM security attributes
  110. */
  111. /**
  112. * struct netlbl_lsm_cache - NetLabel LSM security attribute cache
  113. * @refcount: atomic reference counter
  114. * @free: LSM supplied function to free the cache data
  115. * @data: LSM supplied cache data
  116. *
  117. * Description:
  118. * This structure is provided for LSMs which wish to make use of the NetLabel
  119. * caching mechanism to store LSM specific data/attributes in the NetLabel
  120. * cache. If the LSM has to perform a lot of translation from the NetLabel
  121. * security attributes into it's own internal representation then the cache
  122. * mechanism can provide a way to eliminate some or all of that translation
  123. * overhead on a cache hit.
  124. *
  125. */
  126. struct netlbl_lsm_cache {
  127. atomic_t refcount;
  128. void (*free) (const void *data);
  129. void *data;
  130. };
  131. /**
  132. * struct netlbl_lsm_catmap - NetLabel LSM secattr category bitmap
  133. * @startbit: the value of the lowest order bit in the bitmap
  134. * @bitmap: the category bitmap
  135. * @next: pointer to the next bitmap "node" or NULL
  136. *
  137. * Description:
  138. * This structure is used to represent category bitmaps. Due to the large
  139. * number of categories supported by most labeling protocols it is not
  140. * practical to transfer a full bitmap internally so NetLabel adopts a sparse
  141. * bitmap structure modeled after SELinux's ebitmap structure.
  142. * The catmap bitmap field MUST be a power of two in length and large
  143. * enough to hold at least 240 bits. Special care (i.e. check the code!)
  144. * should be used when changing these values as the LSM implementation
  145. * probably has functions which rely on the sizes of these types to speed
  146. * processing.
  147. *
  148. */
  149. #define NETLBL_CATMAP_MAPTYPE u64
  150. #define NETLBL_CATMAP_MAPCNT 4
  151. #define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8)
  152. #define NETLBL_CATMAP_SIZE (NETLBL_CATMAP_MAPSIZE * \
  153. NETLBL_CATMAP_MAPCNT)
  154. #define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01
  155. struct netlbl_lsm_catmap {
  156. u32 startbit;
  157. NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT];
  158. struct netlbl_lsm_catmap *next;
  159. };
  160. /**
  161. * struct netlbl_lsm_secattr - NetLabel LSM security attributes
  162. * @flags: indicate structure attributes, see NETLBL_SECATTR_*
  163. * @type: indicate the NLTYPE of the attributes
  164. * @domain: the NetLabel LSM domain
  165. * @cache: NetLabel LSM specific cache
  166. * @attr.mls: MLS sensitivity label
  167. * @attr.mls.cat: MLS category bitmap
  168. * @attr.mls.lvl: MLS sensitivity level
  169. * @attr.secid: LSM specific secid token
  170. *
  171. * Description:
  172. * This structure is used to pass security attributes between NetLabel and the
  173. * LSM modules. The flags field is used to specify which fields within the
  174. * struct are valid and valid values can be created by bitwise OR'ing the
  175. * NETLBL_SECATTR_* defines. The domain field is typically set by the LSM to
  176. * specify domain specific configuration settings and is not usually used by
  177. * NetLabel itself when returning security attributes to the LSM.
  178. *
  179. */
  180. struct netlbl_lsm_secattr {
  181. u32 flags;
  182. /* bitmap values for 'flags' */
  183. #define NETLBL_SECATTR_NONE 0x00000000
  184. #define NETLBL_SECATTR_DOMAIN 0x00000001
  185. #define NETLBL_SECATTR_DOMAIN_CPY (NETLBL_SECATTR_DOMAIN | \
  186. NETLBL_SECATTR_FREE_DOMAIN)
  187. #define NETLBL_SECATTR_CACHE 0x00000002
  188. #define NETLBL_SECATTR_MLS_LVL 0x00000004
  189. #define NETLBL_SECATTR_MLS_CAT 0x00000008
  190. #define NETLBL_SECATTR_SECID 0x00000010
  191. /* bitmap meta-values for 'flags' */
  192. #define NETLBL_SECATTR_FREE_DOMAIN 0x01000000
  193. #define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \
  194. NETLBL_SECATTR_MLS_CAT | \
  195. NETLBL_SECATTR_SECID)
  196. u32 type;
  197. char *domain;
  198. struct netlbl_lsm_cache *cache;
  199. struct {
  200. struct {
  201. struct netlbl_lsm_catmap *cat;
  202. u32 lvl;
  203. } mls;
  204. u32 secid;
  205. } attr;
  206. };
  207. /**
  208. * struct netlbl_calipso_ops - NetLabel CALIPSO operations
  209. * @doi_add: add a CALIPSO DOI
  210. * @doi_free: free a CALIPSO DOI
  211. * @doi_getdef: returns a reference to a DOI
  212. * @doi_putdef: releases a reference of a DOI
  213. * @doi_walk: enumerate the DOI list
  214. * @sock_getattr: retrieve the socket's attr
  215. * @sock_setattr: set the socket's attr
  216. * @sock_delattr: remove the socket's attr
  217. * @req_setattr: set the req socket's attr
  218. * @req_delattr: remove the req socket's attr
  219. * @opt_getattr: retrieve attr from memory block
  220. * @skbuff_optptr: find option in packet
  221. * @skbuff_setattr: set the skbuff's attr
  222. * @skbuff_delattr: remove the skbuff's attr
  223. * @cache_invalidate: invalidate cache
  224. * @cache_add: add cache entry
  225. *
  226. * Description:
  227. * This structure is filled out by the CALIPSO engine and passed
  228. * to the NetLabel core via a call to netlbl_calipso_ops_register().
  229. * It enables the CALIPSO engine (and hence IPv6) to be compiled
  230. * as a module.
  231. */
  232. struct netlbl_calipso_ops {
  233. int (*doi_add)(struct calipso_doi *doi_def,
  234. struct netlbl_audit *audit_info);
  235. void (*doi_free)(struct calipso_doi *doi_def);
  236. int (*doi_remove)(u32 doi, struct netlbl_audit *audit_info);
  237. struct calipso_doi *(*doi_getdef)(u32 doi);
  238. void (*doi_putdef)(struct calipso_doi *doi_def);
  239. int (*doi_walk)(u32 *skip_cnt,
  240. int (*callback)(struct calipso_doi *doi_def, void *arg),
  241. void *cb_arg);
  242. int (*sock_getattr)(struct sock *sk,
  243. struct netlbl_lsm_secattr *secattr);
  244. int (*sock_setattr)(struct sock *sk,
  245. const struct calipso_doi *doi_def,
  246. const struct netlbl_lsm_secattr *secattr);
  247. void (*sock_delattr)(struct sock *sk);
  248. int (*req_setattr)(struct request_sock *req,
  249. const struct calipso_doi *doi_def,
  250. const struct netlbl_lsm_secattr *secattr);
  251. void (*req_delattr)(struct request_sock *req);
  252. int (*opt_getattr)(const unsigned char *calipso,
  253. struct netlbl_lsm_secattr *secattr);
  254. unsigned char *(*skbuff_optptr)(const struct sk_buff *skb);
  255. int (*skbuff_setattr)(struct sk_buff *skb,
  256. const struct calipso_doi *doi_def,
  257. const struct netlbl_lsm_secattr *secattr);
  258. int (*skbuff_delattr)(struct sk_buff *skb);
  259. void (*cache_invalidate)(void);
  260. int (*cache_add)(const unsigned char *calipso_ptr,
  261. const struct netlbl_lsm_secattr *secattr);
  262. };
  263. /*
  264. * LSM security attribute operations (inline)
  265. */
  266. /**
  267. * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache
  268. * @flags: the memory allocation flags
  269. *
  270. * Description:
  271. * Allocate and initialize a netlbl_lsm_cache structure. Returns a pointer
  272. * on success, NULL on failure.
  273. *
  274. */
  275. static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc(gfp_t flags)
  276. {
  277. struct netlbl_lsm_cache *cache;
  278. cache = kzalloc(sizeof(*cache), flags);
  279. if (cache)
  280. atomic_set(&cache->refcount, 1);
  281. return cache;
  282. }
  283. /**
  284. * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
  285. * @cache: the struct to free
  286. *
  287. * Description:
  288. * Frees @secattr including all of the internal buffers.
  289. *
  290. */
  291. static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
  292. {
  293. if (!atomic_dec_and_test(&cache->refcount))
  294. return;
  295. if (cache->free)
  296. cache->free(cache->data);
  297. kfree(cache);
  298. }
  299. /**
  300. * netlbl_catmap_alloc - Allocate a LSM secattr catmap
  301. * @flags: memory allocation flags
  302. *
  303. * Description:
  304. * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
  305. * on failure.
  306. *
  307. */
  308. static inline struct netlbl_lsm_catmap *netlbl_catmap_alloc(gfp_t flags)
  309. {
  310. return kzalloc(sizeof(struct netlbl_lsm_catmap), flags);
  311. }
  312. /**
  313. * netlbl_catmap_free - Free a LSM secattr catmap
  314. * @catmap: the category bitmap
  315. *
  316. * Description:
  317. * Free a LSM secattr catmap.
  318. *
  319. */
  320. static inline void netlbl_catmap_free(struct netlbl_lsm_catmap *catmap)
  321. {
  322. struct netlbl_lsm_catmap *iter;
  323. while (catmap) {
  324. iter = catmap;
  325. catmap = catmap->next;
  326. kfree(iter);
  327. }
  328. }
  329. /**
  330. * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
  331. * @secattr: the struct to initialize
  332. *
  333. * Description:
  334. * Initialize an already allocated netlbl_lsm_secattr struct.
  335. *
  336. */
  337. static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
  338. {
  339. memset(secattr, 0, sizeof(*secattr));
  340. }
  341. /**
  342. * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct
  343. * @secattr: the struct to clear
  344. *
  345. * Description:
  346. * Destroys the @secattr struct, including freeing all of the internal buffers.
  347. * The struct must be reset with a call to netlbl_secattr_init() before reuse.
  348. *
  349. */
  350. static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
  351. {
  352. if (secattr->flags & NETLBL_SECATTR_FREE_DOMAIN)
  353. kfree(secattr->domain);
  354. if (secattr->flags & NETLBL_SECATTR_CACHE)
  355. netlbl_secattr_cache_free(secattr->cache);
  356. if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
  357. netlbl_catmap_free(secattr->attr.mls.cat);
  358. }
  359. /**
  360. * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
  361. * @flags: the memory allocation flags
  362. *
  363. * Description:
  364. * Allocate and initialize a netlbl_lsm_secattr struct. Returns a valid
  365. * pointer on success, or NULL on failure.
  366. *
  367. */
  368. static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(gfp_t flags)
  369. {
  370. return kzalloc(sizeof(struct netlbl_lsm_secattr), flags);
  371. }
  372. /**
  373. * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
  374. * @secattr: the struct to free
  375. *
  376. * Description:
  377. * Frees @secattr including all of the internal buffers.
  378. *
  379. */
  380. static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
  381. {
  382. netlbl_secattr_destroy(secattr);
  383. kfree(secattr);
  384. }
  385. #ifdef CONFIG_NETLABEL
  386. /*
  387. * LSM configuration operations
  388. */
  389. int netlbl_cfg_map_del(const char *domain,
  390. u16 family,
  391. const void *addr,
  392. const void *mask,
  393. struct netlbl_audit *audit_info);
  394. int netlbl_cfg_unlbl_map_add(const char *domain,
  395. u16 family,
  396. const void *addr,
  397. const void *mask,
  398. struct netlbl_audit *audit_info);
  399. int netlbl_cfg_unlbl_static_add(struct net *net,
  400. const char *dev_name,
  401. const void *addr,
  402. const void *mask,
  403. u16 family,
  404. u32 secid,
  405. struct netlbl_audit *audit_info);
  406. int netlbl_cfg_unlbl_static_del(struct net *net,
  407. const char *dev_name,
  408. const void *addr,
  409. const void *mask,
  410. u16 family,
  411. struct netlbl_audit *audit_info);
  412. int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  413. struct netlbl_audit *audit_info);
  414. void netlbl_cfg_cipsov4_del(u32 doi, struct netlbl_audit *audit_info);
  415. int netlbl_cfg_cipsov4_map_add(u32 doi,
  416. const char *domain,
  417. const struct in_addr *addr,
  418. const struct in_addr *mask,
  419. struct netlbl_audit *audit_info);
  420. int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
  421. struct netlbl_audit *audit_info);
  422. void netlbl_cfg_calipso_del(u32 doi, struct netlbl_audit *audit_info);
  423. int netlbl_cfg_calipso_map_add(u32 doi,
  424. const char *domain,
  425. const struct in6_addr *addr,
  426. const struct in6_addr *mask,
  427. struct netlbl_audit *audit_info);
  428. /*
  429. * LSM security attribute operations
  430. */
  431. int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset);
  432. int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap, u32 offset);
  433. int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  434. u32 *offset,
  435. unsigned long *bitmap);
  436. int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  437. u32 bit,
  438. gfp_t flags);
  439. int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  440. u32 start,
  441. u32 end,
  442. gfp_t flags);
  443. int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  444. u32 offset,
  445. unsigned long bitmap,
  446. gfp_t flags);
  447. /* Bitmap functions
  448. */
  449. int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,
  450. u32 offset, u8 state);
  451. void netlbl_bitmap_setbit(unsigned char *bitmap, u32 bit, u8 state);
  452. /*
  453. * LSM protocol operations (NetLabel LSM/kernel API)
  454. */
  455. int netlbl_enabled(void);
  456. int netlbl_sock_setattr(struct sock *sk,
  457. u16 family,
  458. const struct netlbl_lsm_secattr *secattr);
  459. void netlbl_sock_delattr(struct sock *sk);
  460. int netlbl_sock_getattr(struct sock *sk,
  461. struct netlbl_lsm_secattr *secattr);
  462. int netlbl_conn_setattr(struct sock *sk,
  463. struct sockaddr *addr,
  464. const struct netlbl_lsm_secattr *secattr);
  465. int netlbl_req_setattr(struct request_sock *req,
  466. const struct netlbl_lsm_secattr *secattr);
  467. void netlbl_req_delattr(struct request_sock *req);
  468. int netlbl_skbuff_setattr(struct sk_buff *skb,
  469. u16 family,
  470. const struct netlbl_lsm_secattr *secattr);
  471. int netlbl_skbuff_getattr(const struct sk_buff *skb,
  472. u16 family,
  473. struct netlbl_lsm_secattr *secattr);
  474. void netlbl_skbuff_err(struct sk_buff *skb, u16 family, int error, int gateway);
  475. /*
  476. * LSM label mapping cache operations
  477. */
  478. void netlbl_cache_invalidate(void);
  479. int netlbl_cache_add(const struct sk_buff *skb, u16 family,
  480. const struct netlbl_lsm_secattr *secattr);
  481. /*
  482. * Protocol engine operations
  483. */
  484. struct audit_buffer *netlbl_audit_start(int type,
  485. struct netlbl_audit *audit_info);
  486. #else
  487. static inline int netlbl_cfg_map_del(const char *domain,
  488. u16 family,
  489. const void *addr,
  490. const void *mask,
  491. struct netlbl_audit *audit_info)
  492. {
  493. return -ENOSYS;
  494. }
  495. static inline int netlbl_cfg_unlbl_map_add(const char *domain,
  496. u16 family,
  497. void *addr,
  498. void *mask,
  499. struct netlbl_audit *audit_info)
  500. {
  501. return -ENOSYS;
  502. }
  503. static inline int netlbl_cfg_unlbl_static_add(struct net *net,
  504. const char *dev_name,
  505. const void *addr,
  506. const void *mask,
  507. u16 family,
  508. u32 secid,
  509. struct netlbl_audit *audit_info)
  510. {
  511. return -ENOSYS;
  512. }
  513. static inline int netlbl_cfg_unlbl_static_del(struct net *net,
  514. const char *dev_name,
  515. const void *addr,
  516. const void *mask,
  517. u16 family,
  518. struct netlbl_audit *audit_info)
  519. {
  520. return -ENOSYS;
  521. }
  522. static inline int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  523. struct netlbl_audit *audit_info)
  524. {
  525. return -ENOSYS;
  526. }
  527. static inline void netlbl_cfg_cipsov4_del(u32 doi,
  528. struct netlbl_audit *audit_info)
  529. {
  530. return;
  531. }
  532. static inline int netlbl_cfg_cipsov4_map_add(u32 doi,
  533. const char *domain,
  534. const struct in_addr *addr,
  535. const struct in_addr *mask,
  536. struct netlbl_audit *audit_info)
  537. {
  538. return -ENOSYS;
  539. }
  540. static inline int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
  541. struct netlbl_audit *audit_info)
  542. {
  543. return -ENOSYS;
  544. }
  545. static inline void netlbl_cfg_calipso_del(u32 doi,
  546. struct netlbl_audit *audit_info)
  547. {
  548. return;
  549. }
  550. static inline int netlbl_cfg_calipso_map_add(u32 doi,
  551. const char *domain,
  552. const struct in6_addr *addr,
  553. const struct in6_addr *mask,
  554. struct netlbl_audit *audit_info)
  555. {
  556. return -ENOSYS;
  557. }
  558. static inline int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap,
  559. u32 offset)
  560. {
  561. return -ENOENT;
  562. }
  563. static inline int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap,
  564. u32 offset)
  565. {
  566. return -ENOENT;
  567. }
  568. static inline int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  569. u32 *offset,
  570. unsigned long *bitmap)
  571. {
  572. return 0;
  573. }
  574. static inline int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  575. u32 bit,
  576. gfp_t flags)
  577. {
  578. return 0;
  579. }
  580. static inline int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  581. u32 start,
  582. u32 end,
  583. gfp_t flags)
  584. {
  585. return 0;
  586. }
  587. static inline int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  588. u32 offset,
  589. unsigned long bitmap,
  590. gfp_t flags)
  591. {
  592. return 0;
  593. }
  594. static inline int netlbl_enabled(void)
  595. {
  596. return 0;
  597. }
  598. static inline int netlbl_sock_setattr(struct sock *sk,
  599. u16 family,
  600. const struct netlbl_lsm_secattr *secattr)
  601. {
  602. return -ENOSYS;
  603. }
  604. static inline void netlbl_sock_delattr(struct sock *sk)
  605. {
  606. }
  607. static inline int netlbl_sock_getattr(struct sock *sk,
  608. struct netlbl_lsm_secattr *secattr)
  609. {
  610. return -ENOSYS;
  611. }
  612. static inline int netlbl_conn_setattr(struct sock *sk,
  613. struct sockaddr *addr,
  614. const struct netlbl_lsm_secattr *secattr)
  615. {
  616. return -ENOSYS;
  617. }
  618. static inline int netlbl_req_setattr(struct request_sock *req,
  619. const struct netlbl_lsm_secattr *secattr)
  620. {
  621. return -ENOSYS;
  622. }
  623. static inline void netlbl_req_delattr(struct request_sock *req)
  624. {
  625. return;
  626. }
  627. static inline int netlbl_skbuff_setattr(struct sk_buff *skb,
  628. u16 family,
  629. const struct netlbl_lsm_secattr *secattr)
  630. {
  631. return -ENOSYS;
  632. }
  633. static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
  634. u16 family,
  635. struct netlbl_lsm_secattr *secattr)
  636. {
  637. return -ENOSYS;
  638. }
  639. static inline void netlbl_skbuff_err(struct sk_buff *skb,
  640. int error,
  641. int gateway)
  642. {
  643. return;
  644. }
  645. static inline void netlbl_cache_invalidate(void)
  646. {
  647. return;
  648. }
  649. static inline int netlbl_cache_add(const struct sk_buff *skb, u16 family,
  650. const struct netlbl_lsm_secattr *secattr)
  651. {
  652. return 0;
  653. }
  654. static inline struct audit_buffer *netlbl_audit_start(int type,
  655. struct netlbl_audit *audit_info)
  656. {
  657. return NULL;
  658. }
  659. #endif /* CONFIG_NETLABEL */
  660. const struct netlbl_calipso_ops *
  661. netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops);
  662. #endif /* _NETLABEL_H */