~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv6/ila/ila_main.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <net/genetlink.h>
  3 #include <net/netns/generic.h>
  4 #include <uapi/linux/genetlink.h>
  5 #include "ila.h"
  6 
  7 static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = {
  8         [ILA_ATTR_LOCATOR] = { .type = NLA_U64, },
  9         [ILA_ATTR_LOCATOR_MATCH] = { .type = NLA_U64, },
 10         [ILA_ATTR_IFINDEX] = { .type = NLA_U32, },
 11         [ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, },
 12         [ILA_ATTR_IDENT_TYPE] = { .type = NLA_U8, },
 13 };
 14 
 15 static const struct genl_ops ila_nl_ops[] = {
 16         {
 17                 .cmd = ILA_CMD_ADD,
 18                 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 19                 .doit = ila_xlat_nl_cmd_add_mapping,
 20                 .flags = GENL_ADMIN_PERM,
 21         },
 22         {
 23                 .cmd = ILA_CMD_DEL,
 24                 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 25                 .doit = ila_xlat_nl_cmd_del_mapping,
 26                 .flags = GENL_ADMIN_PERM,
 27         },
 28         {
 29                 .cmd = ILA_CMD_FLUSH,
 30                 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 31                 .doit = ila_xlat_nl_cmd_flush,
 32                 .flags = GENL_ADMIN_PERM,
 33         },
 34         {
 35                 .cmd = ILA_CMD_GET,
 36                 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 37                 .doit = ila_xlat_nl_cmd_get_mapping,
 38                 .start = ila_xlat_nl_dump_start,
 39                 .dumpit = ila_xlat_nl_dump,
 40                 .done = ila_xlat_nl_dump_done,
 41         },
 42 };
 43 
 44 unsigned int ila_net_id;
 45 
 46 struct genl_family ila_nl_family __ro_after_init = {
 47         .hdrsize        = 0,
 48         .name           = ILA_GENL_NAME,
 49         .version        = ILA_GENL_VERSION,
 50         .maxattr        = ILA_ATTR_MAX,
 51         .policy = ila_nl_policy,
 52         .netnsok        = true,
 53         .parallel_ops   = true,
 54         .module         = THIS_MODULE,
 55         .ops            = ila_nl_ops,
 56         .n_ops          = ARRAY_SIZE(ila_nl_ops),
 57         .resv_start_op  = ILA_CMD_FLUSH + 1,
 58 };
 59 
 60 static __net_init int ila_init_net(struct net *net)
 61 {
 62         int err;
 63 
 64         err = ila_xlat_init_net(net);
 65         if (err)
 66                 goto ila_xlat_init_fail;
 67 
 68         return 0;
 69 
 70 ila_xlat_init_fail:
 71         return err;
 72 }
 73 
 74 static __net_exit void ila_pre_exit_net(struct net *net)
 75 {
 76         ila_xlat_pre_exit_net(net);
 77 }
 78 
 79 static __net_exit void ila_exit_net(struct net *net)
 80 {
 81         ila_xlat_exit_net(net);
 82 }
 83 
 84 static struct pernet_operations ila_net_ops = {
 85         .init = ila_init_net,
 86         .pre_exit = ila_pre_exit_net,
 87         .exit = ila_exit_net,
 88         .id   = &ila_net_id,
 89         .size = sizeof(struct ila_net),
 90 };
 91 
 92 static int __init ila_init(void)
 93 {
 94         int ret;
 95 
 96         ret = register_pernet_device(&ila_net_ops);
 97         if (ret)
 98                 goto register_device_fail;
 99 
100         ret = genl_register_family(&ila_nl_family);
101         if (ret)
102                 goto register_family_fail;
103 
104         ret = ila_lwt_init();
105         if (ret)
106                 goto fail_lwt;
107 
108         return 0;
109 
110 fail_lwt:
111         genl_unregister_family(&ila_nl_family);
112 register_family_fail:
113         unregister_pernet_device(&ila_net_ops);
114 register_device_fail:
115         return ret;
116 }
117 
118 static void __exit ila_fini(void)
119 {
120         ila_lwt_fini();
121         genl_unregister_family(&ila_nl_family);
122         unregister_pernet_device(&ila_net_ops);
123 }
124 
125 module_init(ila_init);
126 module_exit(ila_fini);
127 MODULE_AUTHOR("Tom Herbert <tom@herbertland.com>");
128 MODULE_LICENSE("GPL");
129 MODULE_DESCRIPTION("IPv6: Identifier Locator Addressing (ILA)");
130 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php