Skip to content

Commit

Permalink
net/smc: add pnet table namespace support
Browse files Browse the repository at this point in the history
This patch adds namespace support to the pnet table code. Each network
namespace gets its own pnet table. Infiniband and smcd device pnetids
can only be modified in the initial namespace. In other namespaces they
can still be used as if they were set by the underlying hardware.

Signed-off-by: Hans Wippel <hwippel@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hans Wippel authored and davem330 committed Feb 21, 2019
1 parent f3d74b2 commit 64e28b5
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 43 deletions.
28 changes: 28 additions & 0 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include <net/smc.h>
#include <asm/ioctls.h>

#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include "smc_netns.h"

#include "smc.h"
#include "smc_clc.h"
#include "smc_llc.h"
Expand Down Expand Up @@ -1966,10 +1970,33 @@ static const struct net_proto_family smc_sock_family_ops = {
.create = smc_create,
};

unsigned int smc_net_id;

static __net_init int smc_net_init(struct net *net)
{
return smc_pnet_net_init(net);
}

static void __net_exit smc_net_exit(struct net *net)
{
smc_pnet_net_exit(net);
}

static struct pernet_operations smc_net_ops = {
.init = smc_net_init,
.exit = smc_net_exit,
.id = &smc_net_id,
.size = sizeof(struct smc_net),
};

static int __init smc_init(void)
{
int rc;

rc = register_pernet_subsys(&smc_net_ops);
if (rc)
return rc;

rc = smc_pnet_init();
if (rc)
return rc;
Expand Down Expand Up @@ -2035,6 +2062,7 @@ static void __exit smc_exit(void)
proto_unregister(&smc_proto6);
proto_unregister(&smc_proto);
smc_pnet_exit();
unregister_pernet_subsys(&smc_net_ops);
}

module_init(smc_init);
Expand Down
20 changes: 20 additions & 0 deletions net/smc/smc_netns.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Shared Memory Communications
*
* Network namespace definitions.
*
* Copyright IBM Corp. 2018
*/

#ifndef SMC_NETNS_H
#define SMC_NETNS_H

#include "smc_pnet.h"

extern unsigned int smc_net_id;

/* per-network namespace private data */
struct smc_net {
struct smc_pnettable pnettable;
};
#endif

0 comments on commit 64e28b5

Please sign in to comment.