Skip to content

Commit

Permalink
net: Remove CONFIG_KMOD from net/ (towards removing CONFIG_KMOD entir…
Browse files Browse the repository at this point in the history
…ely)

Some code here depends on CONFIG_KMOD to not try to load
protocol modules or similar, replace by CONFIG_MODULES
where more than just request_module depends on CONFIG_KMOD
and and also use try_then_request_module in ebtables.

Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jmberg authored and davem330 committed Oct 16, 2008
1 parent 00269b5 commit 95a5afc
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 46 deletions.
8 changes: 1 addition & 7 deletions net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
#include <linux/poll.h>
#include <net/sock.h>
#include <asm/ioctls.h>

#if defined(CONFIG_KMOD)
#include <linux/kmod.h>
#endif

#include <net/bluetooth/bluetooth.h>

Expand Down Expand Up @@ -145,11 +142,8 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto)
if (proto < 0 || proto >= BT_MAX_PROTO)
return -EINVAL;

#if defined(CONFIG_KMOD)
if (!bt_proto[proto]) {
if (!bt_proto[proto])
request_module("bt-proto-%d", proto);
}
#endif

err = -EPROTONOSUPPORT;

Expand Down
15 changes: 3 additions & 12 deletions net/bridge/netfilter/ebtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,14 @@ find_inlist_lock_noload(struct list_head *head, const char *name, int *error,
return NULL;
}

#ifndef CONFIG_KMOD
#define find_inlist_lock(h,n,p,e,m) find_inlist_lock_noload((h),(n),(e),(m))
#else
static void *
find_inlist_lock(struct list_head *head, const char *name, const char *prefix,
int *error, struct mutex *mutex)
{
void *ret;

ret = find_inlist_lock_noload(head, name, error, mutex);
if (!ret) {
request_module("%s%s", prefix, name);
ret = find_inlist_lock_noload(head, name, error, mutex);
}
return ret;
return try_then_request_module(
find_inlist_lock_noload(head, name, error, mutex),
"%s%s", prefix, name);
}
#endif

static inline struct ebt_table *
find_table_lock(const char *name, int *error, struct mutex *mutex)
Expand Down
4 changes: 2 additions & 2 deletions net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
if (net != &init_net)
return -EAFNOSUPPORT;

#ifdef CONFIG_KMOD
/* try to load protocol module, when CONFIG_KMOD is defined */
#ifdef CONFIG_MODULES
/* try to load protocol module kernel is modular */
if (!proto_tab[protocol]) {
err = request_module("can-proto-%d", protocol);

Expand Down
2 changes: 0 additions & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4956,8 +4956,6 @@ EXPORT_SYMBOL(br_fdb_get_hook);
EXPORT_SYMBOL(br_fdb_put_hook);
#endif

#ifdef CONFIG_KMOD
EXPORT_SYMBOL(dev_load);
#endif

EXPORT_PER_CPU_SYMBOL(softnet_data);
4 changes: 2 additions & 2 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct nlattr *linkinfo[IFLA_INFO_MAX+1];
int err;

#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
replay:
#endif
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
return -EOPNOTSUPP;

if (!ops) {
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
if (kind[0]) {
__rtnl_unlock();
request_module("rtnl-link-%s", kind);
Expand Down
2 changes: 1 addition & 1 deletion net/dccp/ccid.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, gfp_t gfp)
struct ccid *ccid = NULL;

ccids_read_lock();
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
if (ccids[id] == NULL) {
/* We only try to load if in process context */
ccids_read_unlock();
Expand Down
2 changes: 0 additions & 2 deletions net/decnet/dn_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
return -EFAULT;
ifr->ifr_name[IFNAMSIZ-1] = 0;

#ifdef CONFIG_KMOD
dev_load(&init_net, ifr->ifr_name);
#endif

switch(cmd) {
case SIOCGIFADDR:
Expand Down
2 changes: 0 additions & 2 deletions net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
if (colon)
*colon = 0;

#ifdef CONFIG_KMOD
dev_load(net, ifr.ifr_name);
#endif

switch (cmd) {
case SIOCGIFADDR: /* Get interface address */
Expand Down
2 changes: 0 additions & 2 deletions net/ipv4/inet_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ static DEFINE_MUTEX(inet_diag_table_mutex);

static const struct inet_diag_handler *inet_diag_lock_handler(int type)
{
#ifdef CONFIG_KMOD
if (!inet_diag_table[type])
request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
NETLINK_INET_DIAG, type);
#endif

mutex_lock(&inet_diag_table_mutex);
if (!inet_diag_table[type])
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/tcp_cong.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int tcp_set_default_congestion_control(const char *name)

spin_lock(&tcp_cong_list_lock);
ca = tcp_ca_find(name);
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
if (!ca && capable(CAP_SYS_MODULE)) {
spin_unlock(&tcp_cong_list_lock);

Expand Down Expand Up @@ -244,7 +244,7 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
if (ca == icsk->icsk_ca_ops)
goto out;

#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
/* not found attempt to autoload module */
if (!ca && capable(CAP_SYS_MODULE)) {
rcu_read_unlock();
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ ctnetlink_parse_nat_setup(struct nf_conn *ct,

parse_nat_setup = rcu_dereference(nfnetlink_parse_nat_setup_hook);
if (!parse_nat_setup) {
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
rcu_read_unlock();
nfnl_unlock();
if (request_module("nf-nat-ipv4") < 0) {
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nfnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
replay:
ss = nfnetlink_get_subsys(type);
if (!ss) {
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
nfnl_unlock();
request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type));
nfnl_lock();
Expand Down
2 changes: 1 addition & 1 deletion net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static int netlink_create(struct net *net, struct socket *sock, int protocol)
return -EPROTONOSUPPORT;

netlink_lock_table();
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
if (!nl_table[protocol].registered) {
netlink_unlock_table();
request_module("net-pf-%d-proto-%d", PF_NETLINK, protocol);
Expand Down
3 changes: 1 addition & 2 deletions net/phonet/af_phonet.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ static int pn_socket_create(struct net *net, struct socket *sock, int protocol)
}

pnp = phonet_proto_get(protocol);
#ifdef CONFIG_KMOD
if (pnp == NULL &&
request_module("net-pf-%d-proto-%d", PF_PHONET, protocol) == 0)
pnp = phonet_proto_get(protocol);
#endif

if (pnp == NULL)
return -EPROTONOSUPPORT;
if (sock->type != pnp->sock_type) {
Expand Down
2 changes: 1 addition & 1 deletion net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,

a_o = tc_lookup_action_n(act_name);
if (a_o == NULL) {
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
rtnl_unlock();
request_module("act_%s", act_name);
rtnl_lock();
Expand Down
2 changes: 1 addition & 1 deletion net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
err = -ENOENT;
tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND]);
if (tp_ops == NULL) {
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
struct nlattr *kind = tca[TCA_KIND];
char name[IFNAMSIZ];

Expand Down
2 changes: 1 addition & 1 deletion net/sched/ematch.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int tcf_em_validate(struct tcf_proto *tp,

if (em->ops == NULL) {
err = -ENOENT;
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
__rtnl_unlock();
request_module("ematch-kind-%u", em_hdr->kind);
rtnl_lock();
Expand Down
2 changes: 1 addition & 1 deletion net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
struct qdisc_size_table *stab;

ops = qdisc_lookup_ops(kind);
#ifdef CONFIG_KMOD
#ifdef CONFIG_MODULES
if (ops == NULL && kind != NULL) {
char name[IFNAMSIZ];
if (nla_strlcpy(name, kind, IFNAMSIZ) < IFNAMSIZ) {
Expand Down
2 changes: 1 addition & 1 deletion net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ static int __sock_create(struct net *net, int family, int type, int protocol,

sock->type = type;

#if defined(CONFIG_KMOD)
#ifdef CONFIG_MODULES
/* Attempt to load a protocol module if the find failed.
*
* 12/09/1996 Marcin: But! this makes REALLY only sense, if the user
Expand Down
2 changes: 0 additions & 2 deletions net/sunrpc/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ rpcauth_create(rpc_authflavor_t pseudoflavor, struct rpc_clnt *clnt)
if (flavor >= RPC_AUTH_MAXFLAVOR)
goto out;

#ifdef CONFIG_KMOD
if ((ops = auth_flavors[flavor]) == NULL)
request_module("rpc-auth-%u", flavor);
#endif
spin_lock(&rpc_authflavor_lock);
ops = auth_flavors[flavor];
if (ops == NULL || !try_module_get(ops->owner)) {
Expand Down

0 comments on commit 95a5afc

Please sign in to comment.