-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Samuel Cabrero
authored and
Steve French
committed
Dec 14, 2020
1 parent
047092f
commit 06f08da
Showing
6 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Netlink routines for CIFS | ||
* | ||
* Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> | ||
*/ | ||
|
||
#include <net/genetlink.h> | ||
#include <uapi/linux/cifs/cifs_netlink.h> | ||
|
||
#include "netlink.h" | ||
#include "cifsglob.h" | ||
#include "cifs_debug.h" | ||
|
||
static const struct nla_policy cifs_genl_policy[CIFS_GENL_ATTR_MAX + 1] = { | ||
}; | ||
|
||
static struct genl_ops cifs_genl_ops[] = { | ||
}; | ||
|
||
static const struct genl_multicast_group cifs_genl_mcgrps[] = { | ||
[CIFS_GENL_MCGRP_SWN] = { .name = CIFS_GENL_MCGRP_SWN_NAME }, | ||
}; | ||
|
||
struct genl_family cifs_genl_family = { | ||
.name = CIFS_GENL_NAME, | ||
.version = CIFS_GENL_VERSION, | ||
.hdrsize = 0, | ||
.maxattr = CIFS_GENL_ATTR_MAX, | ||
.module = THIS_MODULE, | ||
.policy = cifs_genl_policy, | ||
.ops = cifs_genl_ops, | ||
.n_ops = ARRAY_SIZE(cifs_genl_ops), | ||
.mcgrps = cifs_genl_mcgrps, | ||
.n_mcgrps = ARRAY_SIZE(cifs_genl_mcgrps), | ||
}; | ||
|
||
/** | ||
* cifs_genl_init - Register generic netlink family | ||
* | ||
* Return zero if initialized successfully, otherwise non-zero. | ||
*/ | ||
int cifs_genl_init(void) | ||
{ | ||
int ret; | ||
|
||
ret = genl_register_family(&cifs_genl_family); | ||
if (ret < 0) { | ||
cifs_dbg(VFS, "%s: failed to register netlink family\n", | ||
__func__); | ||
return ret; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* cifs_genl_exit - Unregister generic netlink family | ||
*/ | ||
void cifs_genl_exit(void) | ||
{ | ||
int ret; | ||
|
||
ret = genl_unregister_family(&cifs_genl_family); | ||
if (ret < 0) { | ||
cifs_dbg(VFS, "%s: failed to unregister netlink family\n", | ||
__func__); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Netlink routines for CIFS | ||
* | ||
* Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> | ||
*/ | ||
|
||
#ifndef _CIFS_NETLINK_H | ||
#define _CIFS_NETLINK_H | ||
|
||
extern struct genl_family cifs_genl_family; | ||
|
||
extern int cifs_genl_init(void); | ||
extern void cifs_genl_exit(void); | ||
|
||
#endif /* _CIFS_NETLINK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */ | ||
/* | ||
* Netlink routines for CIFS | ||
* | ||
* Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> | ||
*/ | ||
|
||
|
||
#ifndef _UAPILINUX_CIFS_NETLINK_H | ||
#define _UAPILINUX_CIFS_NETLINK_H | ||
|
||
#define CIFS_GENL_NAME "cifs" | ||
#define CIFS_GENL_VERSION 0x1 | ||
|
||
#define CIFS_GENL_MCGRP_SWN_NAME "cifs_mcgrp_swn" | ||
|
||
enum cifs_genl_multicast_groups { | ||
CIFS_GENL_MCGRP_SWN, | ||
}; | ||
|
||
enum cifs_genl_attributes { | ||
__CIFS_GENL_ATTR_MAX, | ||
}; | ||
#define CIFS_GENL_ATTR_MAX (__CIFS_GENL_ATTR_MAX - 1) | ||
|
||
enum cifs_genl_commands { | ||
__CIFS_GENL_CMD_MAX | ||
}; | ||
#define CIFS_GENL_CMD_MAX (__CIFS_GENL_CMD_MAX - 1) | ||
|
||
#endif /* _UAPILINUX_CIFS_NETLINK_H */ |