netlabel.h 20 KB

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