netlabel.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. *
  218. * Description:
  219. * This structure is filled out by the CALIPSO engine and passed
  220. * to the NetLabel core via a call to netlbl_calipso_ops_register().
  221. * It enables the CALIPSO engine (and hence IPv6) to be compiled
  222. * as a module.
  223. */
  224. struct netlbl_calipso_ops {
  225. int (*doi_add)(struct calipso_doi *doi_def,
  226. struct netlbl_audit *audit_info);
  227. void (*doi_free)(struct calipso_doi *doi_def);
  228. int (*doi_remove)(u32 doi, struct netlbl_audit *audit_info);
  229. struct calipso_doi *(*doi_getdef)(u32 doi);
  230. void (*doi_putdef)(struct calipso_doi *doi_def);
  231. int (*doi_walk)(u32 *skip_cnt,
  232. int (*callback)(struct calipso_doi *doi_def, void *arg),
  233. void *cb_arg);
  234. int (*sock_getattr)(struct sock *sk,
  235. struct netlbl_lsm_secattr *secattr);
  236. int (*sock_setattr)(struct sock *sk,
  237. const struct calipso_doi *doi_def,
  238. const struct netlbl_lsm_secattr *secattr);
  239. void (*sock_delattr)(struct sock *sk);
  240. };
  241. /*
  242. * LSM security attribute operations (inline)
  243. */
  244. /**
  245. * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache
  246. * @flags: the memory allocation flags
  247. *
  248. * Description:
  249. * Allocate and initialize a netlbl_lsm_cache structure. Returns a pointer
  250. * on success, NULL on failure.
  251. *
  252. */
  253. static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc(gfp_t flags)
  254. {
  255. struct netlbl_lsm_cache *cache;
  256. cache = kzalloc(sizeof(*cache), flags);
  257. if (cache)
  258. atomic_set(&cache->refcount, 1);
  259. return cache;
  260. }
  261. /**
  262. * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
  263. * @cache: the struct to free
  264. *
  265. * Description:
  266. * Frees @secattr including all of the internal buffers.
  267. *
  268. */
  269. static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
  270. {
  271. if (!atomic_dec_and_test(&cache->refcount))
  272. return;
  273. if (cache->free)
  274. cache->free(cache->data);
  275. kfree(cache);
  276. }
  277. /**
  278. * netlbl_catmap_alloc - Allocate a LSM secattr catmap
  279. * @flags: memory allocation flags
  280. *
  281. * Description:
  282. * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
  283. * on failure.
  284. *
  285. */
  286. static inline struct netlbl_lsm_catmap *netlbl_catmap_alloc(gfp_t flags)
  287. {
  288. return kzalloc(sizeof(struct netlbl_lsm_catmap), flags);
  289. }
  290. /**
  291. * netlbl_catmap_free - Free a LSM secattr catmap
  292. * @catmap: the category bitmap
  293. *
  294. * Description:
  295. * Free a LSM secattr catmap.
  296. *
  297. */
  298. static inline void netlbl_catmap_free(struct netlbl_lsm_catmap *catmap)
  299. {
  300. struct netlbl_lsm_catmap *iter;
  301. while (catmap) {
  302. iter = catmap;
  303. catmap = catmap->next;
  304. kfree(iter);
  305. }
  306. }
  307. /**
  308. * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
  309. * @secattr: the struct to initialize
  310. *
  311. * Description:
  312. * Initialize an already allocated netlbl_lsm_secattr struct.
  313. *
  314. */
  315. static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
  316. {
  317. memset(secattr, 0, sizeof(*secattr));
  318. }
  319. /**
  320. * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct
  321. * @secattr: the struct to clear
  322. *
  323. * Description:
  324. * Destroys the @secattr struct, including freeing all of the internal buffers.
  325. * The struct must be reset with a call to netlbl_secattr_init() before reuse.
  326. *
  327. */
  328. static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
  329. {
  330. if (secattr->flags & NETLBL_SECATTR_FREE_DOMAIN)
  331. kfree(secattr->domain);
  332. if (secattr->flags & NETLBL_SECATTR_CACHE)
  333. netlbl_secattr_cache_free(secattr->cache);
  334. if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
  335. netlbl_catmap_free(secattr->attr.mls.cat);
  336. }
  337. /**
  338. * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
  339. * @flags: the memory allocation flags
  340. *
  341. * Description:
  342. * Allocate and initialize a netlbl_lsm_secattr struct. Returns a valid
  343. * pointer on success, or NULL on failure.
  344. *
  345. */
  346. static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(gfp_t flags)
  347. {
  348. return kzalloc(sizeof(struct netlbl_lsm_secattr), flags);
  349. }
  350. /**
  351. * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
  352. * @secattr: the struct to free
  353. *
  354. * Description:
  355. * Frees @secattr including all of the internal buffers.
  356. *
  357. */
  358. static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
  359. {
  360. netlbl_secattr_destroy(secattr);
  361. kfree(secattr);
  362. }
  363. #ifdef CONFIG_NETLABEL
  364. /*
  365. * LSM configuration operations
  366. */
  367. int netlbl_cfg_map_del(const char *domain,
  368. u16 family,
  369. const void *addr,
  370. const void *mask,
  371. struct netlbl_audit *audit_info);
  372. int netlbl_cfg_unlbl_map_add(const char *domain,
  373. u16 family,
  374. const void *addr,
  375. const void *mask,
  376. struct netlbl_audit *audit_info);
  377. int netlbl_cfg_unlbl_static_add(struct net *net,
  378. const char *dev_name,
  379. const void *addr,
  380. const void *mask,
  381. u16 family,
  382. u32 secid,
  383. struct netlbl_audit *audit_info);
  384. int netlbl_cfg_unlbl_static_del(struct net *net,
  385. const char *dev_name,
  386. const void *addr,
  387. const void *mask,
  388. u16 family,
  389. struct netlbl_audit *audit_info);
  390. int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  391. struct netlbl_audit *audit_info);
  392. void netlbl_cfg_cipsov4_del(u32 doi, struct netlbl_audit *audit_info);
  393. int netlbl_cfg_cipsov4_map_add(u32 doi,
  394. const char *domain,
  395. const struct in_addr *addr,
  396. const struct in_addr *mask,
  397. struct netlbl_audit *audit_info);
  398. /*
  399. * LSM security attribute operations
  400. */
  401. int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset);
  402. int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap, u32 offset);
  403. int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  404. u32 *offset,
  405. unsigned long *bitmap);
  406. int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  407. u32 bit,
  408. gfp_t flags);
  409. int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  410. u32 start,
  411. u32 end,
  412. gfp_t flags);
  413. int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  414. u32 offset,
  415. unsigned long bitmap,
  416. gfp_t flags);
  417. /* Bitmap functions
  418. */
  419. int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,
  420. u32 offset, u8 state);
  421. void netlbl_bitmap_setbit(unsigned char *bitmap, u32 bit, u8 state);
  422. /*
  423. * LSM protocol operations (NetLabel LSM/kernel API)
  424. */
  425. int netlbl_enabled(void);
  426. int netlbl_sock_setattr(struct sock *sk,
  427. u16 family,
  428. const struct netlbl_lsm_secattr *secattr);
  429. void netlbl_sock_delattr(struct sock *sk);
  430. int netlbl_sock_getattr(struct sock *sk,
  431. struct netlbl_lsm_secattr *secattr);
  432. int netlbl_conn_setattr(struct sock *sk,
  433. struct sockaddr *addr,
  434. const struct netlbl_lsm_secattr *secattr);
  435. int netlbl_req_setattr(struct request_sock *req,
  436. const struct netlbl_lsm_secattr *secattr);
  437. void netlbl_req_delattr(struct request_sock *req);
  438. int netlbl_skbuff_setattr(struct sk_buff *skb,
  439. u16 family,
  440. const struct netlbl_lsm_secattr *secattr);
  441. int netlbl_skbuff_getattr(const struct sk_buff *skb,
  442. u16 family,
  443. struct netlbl_lsm_secattr *secattr);
  444. void netlbl_skbuff_err(struct sk_buff *skb, int error, int gateway);
  445. /*
  446. * LSM label mapping cache operations
  447. */
  448. void netlbl_cache_invalidate(void);
  449. int netlbl_cache_add(const struct sk_buff *skb,
  450. const struct netlbl_lsm_secattr *secattr);
  451. /*
  452. * Protocol engine operations
  453. */
  454. struct audit_buffer *netlbl_audit_start(int type,
  455. struct netlbl_audit *audit_info);
  456. #else
  457. static inline int netlbl_cfg_map_del(const char *domain,
  458. u16 family,
  459. const void *addr,
  460. const void *mask,
  461. struct netlbl_audit *audit_info)
  462. {
  463. return -ENOSYS;
  464. }
  465. static inline int netlbl_cfg_unlbl_map_add(const char *domain,
  466. u16 family,
  467. void *addr,
  468. void *mask,
  469. struct netlbl_audit *audit_info)
  470. {
  471. return -ENOSYS;
  472. }
  473. static inline int netlbl_cfg_unlbl_static_add(struct net *net,
  474. const char *dev_name,
  475. const void *addr,
  476. const void *mask,
  477. u16 family,
  478. u32 secid,
  479. struct netlbl_audit *audit_info)
  480. {
  481. return -ENOSYS;
  482. }
  483. static inline int netlbl_cfg_unlbl_static_del(struct net *net,
  484. const char *dev_name,
  485. const void *addr,
  486. const void *mask,
  487. u16 family,
  488. struct netlbl_audit *audit_info)
  489. {
  490. return -ENOSYS;
  491. }
  492. static inline int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  493. struct netlbl_audit *audit_info)
  494. {
  495. return -ENOSYS;
  496. }
  497. static inline void netlbl_cfg_cipsov4_del(u32 doi,
  498. struct netlbl_audit *audit_info)
  499. {
  500. return;
  501. }
  502. static inline int netlbl_cfg_cipsov4_map_add(u32 doi,
  503. const char *domain,
  504. const struct in_addr *addr,
  505. const struct in_addr *mask,
  506. struct netlbl_audit *audit_info)
  507. {
  508. return -ENOSYS;
  509. }
  510. static inline int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap,
  511. u32 offset)
  512. {
  513. return -ENOENT;
  514. }
  515. static inline int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap,
  516. u32 offset)
  517. {
  518. return -ENOENT;
  519. }
  520. static inline int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  521. u32 *offset,
  522. unsigned long *bitmap)
  523. {
  524. return 0;
  525. }
  526. static inline int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  527. u32 bit,
  528. gfp_t flags)
  529. {
  530. return 0;
  531. }
  532. static inline int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  533. u32 start,
  534. u32 end,
  535. gfp_t flags)
  536. {
  537. return 0;
  538. }
  539. static inline int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  540. u32 offset,
  541. unsigned long bitmap,
  542. gfp_t flags)
  543. {
  544. return 0;
  545. }
  546. static inline int netlbl_enabled(void)
  547. {
  548. return 0;
  549. }
  550. static inline int netlbl_sock_setattr(struct sock *sk,
  551. u16 family,
  552. const struct netlbl_lsm_secattr *secattr)
  553. {
  554. return -ENOSYS;
  555. }
  556. static inline void netlbl_sock_delattr(struct sock *sk)
  557. {
  558. }
  559. static inline int netlbl_sock_getattr(struct sock *sk,
  560. struct netlbl_lsm_secattr *secattr)
  561. {
  562. return -ENOSYS;
  563. }
  564. static inline int netlbl_conn_setattr(struct sock *sk,
  565. struct sockaddr *addr,
  566. const struct netlbl_lsm_secattr *secattr)
  567. {
  568. return -ENOSYS;
  569. }
  570. static inline int netlbl_req_setattr(struct request_sock *req,
  571. const struct netlbl_lsm_secattr *secattr)
  572. {
  573. return -ENOSYS;
  574. }
  575. static inline void netlbl_req_delattr(struct request_sock *req)
  576. {
  577. return;
  578. }
  579. static inline int netlbl_skbuff_setattr(struct sk_buff *skb,
  580. u16 family,
  581. const struct netlbl_lsm_secattr *secattr)
  582. {
  583. return -ENOSYS;
  584. }
  585. static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
  586. u16 family,
  587. struct netlbl_lsm_secattr *secattr)
  588. {
  589. return -ENOSYS;
  590. }
  591. static inline void netlbl_skbuff_err(struct sk_buff *skb,
  592. int error,
  593. int gateway)
  594. {
  595. return;
  596. }
  597. static inline void netlbl_cache_invalidate(void)
  598. {
  599. return;
  600. }
  601. static inline int netlbl_cache_add(const struct sk_buff *skb,
  602. const struct netlbl_lsm_secattr *secattr)
  603. {
  604. return 0;
  605. }
  606. static inline struct audit_buffer *netlbl_audit_start(int type,
  607. struct netlbl_audit *audit_info)
  608. {
  609. return NULL;
  610. }
  611. #endif /* CONFIG_NETLABEL */
  612. const struct netlbl_calipso_ops *
  613. netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops);
  614. #endif /* _NETLABEL_H */