Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cifs: Register generic netlink family

Register a new generic netlink family to talk to the witness service
userspace daemon.

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Samuel Cabrero and committed by
Steve French
06f08dab 047092ff

+145 -1
+11
fs/cifs/Kconfig
··· 190 190 servers if their addresses change or for implicit mounts of 191 191 DFS junction points. If unsure, say Y. 192 192 193 + config CIFS_SWN_UPCALL 194 + bool "SWN feature support" 195 + depends on CIFS 196 + help 197 + The Service Witness Protocol (SWN) is used to get notifications 198 + from a highly available server of resource state changes. This 199 + feature enables an upcall mechanism for CIFS which contacts an 200 + userspace daemon to establish the DCE/RPC connection to retrieve 201 + the cluster available interfaces and resource change notifications. 202 + If unsure, say Y. 203 + 193 204 config CIFS_NFSD_EXPORT 194 205 bool "Allow nfsd to export CIFS file system" 195 206 depends on CIFS && BROKEN
+2
fs/cifs/Makefile
··· 18 18 19 19 cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o dfs_cache.o 20 20 21 + cifs-$(CONFIG_CIFS_SWN_UPCALL) += netlink.o 22 + 21 23 cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o 22 24 23 25 cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o
+16 -1
fs/cifs/cifsfs.c
··· 55 55 #ifdef CONFIG_CIFS_DFS_UPCALL 56 56 #include "dfs_cache.h" 57 57 #endif 58 + #ifdef CONFIG_CIFS_SWN_UPCALL 59 + #include "netlink.h" 60 + #endif 58 61 #include "fs_context.h" 59 62 60 63 /* ··· 1604 1601 if (rc) 1605 1602 goto out_destroy_dfs_cache; 1606 1603 #endif /* CONFIG_CIFS_UPCALL */ 1604 + #ifdef CONFIG_CIFS_SWN_UPCALL 1605 + rc = cifs_genl_init(); 1606 + if (rc) 1607 + goto out_register_key_type; 1608 + #endif /* CONFIG_CIFS_SWN_UPCALL */ 1607 1609 1608 1610 rc = init_cifs_idmap(); 1609 1611 if (rc) 1610 - goto out_register_key_type; 1612 + goto out_cifs_swn_init; 1611 1613 1612 1614 rc = register_filesystem(&cifs_fs_type); 1613 1615 if (rc) ··· 1628 1620 1629 1621 out_init_cifs_idmap: 1630 1622 exit_cifs_idmap(); 1623 + out_cifs_swn_init: 1624 + #ifdef CONFIG_CIFS_SWN_UPCALL 1625 + cifs_genl_exit(); 1631 1626 out_register_key_type: 1627 + #endif 1632 1628 #ifdef CONFIG_CIFS_UPCALL 1633 1629 exit_cifs_spnego(); 1634 1630 out_destroy_dfs_cache: ··· 1669 1657 unregister_filesystem(&smb3_fs_type); 1670 1658 cifs_dfs_release_automount_timer(); 1671 1659 exit_cifs_idmap(); 1660 + #ifdef CONFIG_CIFS_SWN_UPCALL 1661 + cifs_genl_exit(); 1662 + #endif 1672 1663 #ifdef CONFIG_CIFS_UPCALL 1673 1664 exit_cifs_spnego(); 1674 1665 #endif
+69
fs/cifs/netlink.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Netlink routines for CIFS 4 + * 5 + * Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> 6 + */ 7 + 8 + #include <net/genetlink.h> 9 + #include <uapi/linux/cifs/cifs_netlink.h> 10 + 11 + #include "netlink.h" 12 + #include "cifsglob.h" 13 + #include "cifs_debug.h" 14 + 15 + static const struct nla_policy cifs_genl_policy[CIFS_GENL_ATTR_MAX + 1] = { 16 + }; 17 + 18 + static struct genl_ops cifs_genl_ops[] = { 19 + }; 20 + 21 + static const struct genl_multicast_group cifs_genl_mcgrps[] = { 22 + [CIFS_GENL_MCGRP_SWN] = { .name = CIFS_GENL_MCGRP_SWN_NAME }, 23 + }; 24 + 25 + struct genl_family cifs_genl_family = { 26 + .name = CIFS_GENL_NAME, 27 + .version = CIFS_GENL_VERSION, 28 + .hdrsize = 0, 29 + .maxattr = CIFS_GENL_ATTR_MAX, 30 + .module = THIS_MODULE, 31 + .policy = cifs_genl_policy, 32 + .ops = cifs_genl_ops, 33 + .n_ops = ARRAY_SIZE(cifs_genl_ops), 34 + .mcgrps = cifs_genl_mcgrps, 35 + .n_mcgrps = ARRAY_SIZE(cifs_genl_mcgrps), 36 + }; 37 + 38 + /** 39 + * cifs_genl_init - Register generic netlink family 40 + * 41 + * Return zero if initialized successfully, otherwise non-zero. 42 + */ 43 + int cifs_genl_init(void) 44 + { 45 + int ret; 46 + 47 + ret = genl_register_family(&cifs_genl_family); 48 + if (ret < 0) { 49 + cifs_dbg(VFS, "%s: failed to register netlink family\n", 50 + __func__); 51 + return ret; 52 + } 53 + 54 + return 0; 55 + } 56 + 57 + /** 58 + * cifs_genl_exit - Unregister generic netlink family 59 + */ 60 + void cifs_genl_exit(void) 61 + { 62 + int ret; 63 + 64 + ret = genl_unregister_family(&cifs_genl_family); 65 + if (ret < 0) { 66 + cifs_dbg(VFS, "%s: failed to unregister netlink family\n", 67 + __func__); 68 + } 69 + }
+16
fs/cifs/netlink.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Netlink routines for CIFS 4 + * 5 + * Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> 6 + */ 7 + 8 + #ifndef _CIFS_NETLINK_H 9 + #define _CIFS_NETLINK_H 10 + 11 + extern struct genl_family cifs_genl_family; 12 + 13 + extern int cifs_genl_init(void); 14 + extern void cifs_genl_exit(void); 15 + 16 + #endif /* _CIFS_NETLINK_H */
+31
include/uapi/linux/cifs/cifs_netlink.h
··· 1 + /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */ 2 + /* 3 + * Netlink routines for CIFS 4 + * 5 + * Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> 6 + */ 7 + 8 + 9 + #ifndef _UAPILINUX_CIFS_NETLINK_H 10 + #define _UAPILINUX_CIFS_NETLINK_H 11 + 12 + #define CIFS_GENL_NAME "cifs" 13 + #define CIFS_GENL_VERSION 0x1 14 + 15 + #define CIFS_GENL_MCGRP_SWN_NAME "cifs_mcgrp_swn" 16 + 17 + enum cifs_genl_multicast_groups { 18 + CIFS_GENL_MCGRP_SWN, 19 + }; 20 + 21 + enum cifs_genl_attributes { 22 + __CIFS_GENL_ATTR_MAX, 23 + }; 24 + #define CIFS_GENL_ATTR_MAX (__CIFS_GENL_ATTR_MAX - 1) 25 + 26 + enum cifs_genl_commands { 27 + __CIFS_GENL_CMD_MAX 28 + }; 29 + #define CIFS_GENL_CMD_MAX (__CIFS_GENL_CMD_MAX - 1) 30 + 31 + #endif /* _UAPILINUX_CIFS_NETLINK_H */