netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <dlezcano@fr.ibm.com>
To: davem@davemloft.net
Cc: benjamin.thery@bull.net, netdev@vger.kernel.org, den@openvz.org
Subject: [patch 08/11][NETNS][IPV6] fib6_rules - dynamically allocate the fib rules ops
Date: Fri, 25 Jan 2008 17:50:16 +0100	[thread overview]
Message-ID: <20080125170818.796719655@localhost.localdomain> (raw)
In-Reply-To: 20080125165008.317745745@localhost.localdomain

[-- Attachment #1: fib6-rules-dynamic-allocation.patch --]
[-- Type: text/plain, Size: 2897 bytes --]

The fib6_rules_ops structure is dynamically allocated, so that allows
to make several instances of it per network namespace.

The global static fib6_rules_ops structure is renamed to 
fib6_rules_ops_template in order to quickly memcopy it for the
structure initialization.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
 net/ipv6/fib6_rules.c |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

Index: net-2.6.25/net/ipv6/fib6_rules.c
===================================================================
--- net-2.6.25.orig/net/ipv6/fib6_rules.c
+++ net-2.6.25/net/ipv6/fib6_rules.c
@@ -29,7 +29,7 @@ struct fib6_rule
 	u8			tclass;
 };
 
-static struct fib_rules_ops fib6_rules_ops;
+static struct fib_rules_ops *fib6_rules_ops;
 
 struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl,
 				   int flags, pol_lookup_t lookup)
@@ -38,7 +38,7 @@ struct dst_entry *fib6_rule_lookup(struc
 		.lookup_ptr = lookup,
 	};
 
-	fib_rules_lookup(&fib6_rules_ops, fl, flags, &arg);
+	fib_rules_lookup(fib6_rules_ops, fl, flags, &arg);
 	if (arg.rule)
 		fib_rule_put(arg.rule);
 
@@ -234,7 +234,7 @@ static size_t fib6_rule_nlmsg_payload(st
 	       + nla_total_size(16); /* src */
 }
 
-static struct fib_rules_ops fib6_rules_ops = {
+static struct fib_rules_ops fib6_rules_ops_template = {
 	.family			= AF_INET6,
 	.rule_size		= sizeof(struct fib6_rule),
 	.addr_size		= sizeof(struct in6_addr),
@@ -247,7 +247,6 @@ static struct fib_rules_ops fib6_rules_o
 	.nlmsg_payload		= fib6_rule_nlmsg_payload,
 	.nlgroup		= RTNLGRP_IPV6_RULE,
 	.policy			= fib6_rule_policy,
-	.rules_list		= LIST_HEAD_INIT(fib6_rules_ops.rules_list),
 	.owner			= THIS_MODULE,
 	.fro_net		= &init_net,
 };
@@ -256,11 +255,18 @@ static int __init fib6_default_rules_ini
 {
 	int err;
 
-	err = fib_default_rule_add(&fib6_rules_ops, 0,
+	fib6_rules_ops = kmemdup(&fib6_rules_ops_template,
+				 sizeof(*fib6_rules_ops), GFP_KERNEL);
+	if (!fib6_rules_ops)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&fib6_rules_ops->rules_list);
+
+	err = fib_default_rule_add(fib6_rules_ops, 0,
 				   RT6_TABLE_LOCAL, FIB_RULE_PERMANENT);
 	if (err < 0)
 		return err;
-	err = fib_default_rule_add(&fib6_rules_ops, 0x7FFE, RT6_TABLE_MAIN, 0);
+	err = fib_default_rule_add(fib6_rules_ops, 0x7FFE, RT6_TABLE_MAIN, 0);
 	if (err < 0)
 		return err;
 	return 0;
@@ -274,18 +280,20 @@ int __init fib6_rules_init(void)
 	if (ret)
 		goto out;
 
-	ret = fib_rules_register(&fib6_rules_ops);
+	ret = fib_rules_register(fib6_rules_ops);
 	if (ret)
 		goto out_default_rules_init;
 out:
 	return ret;
 
 out_default_rules_init:
-	fib_rules_cleanup_ops(&fib6_rules_ops);
+	fib_rules_cleanup_ops(fib6_rules_ops);
+	kfree(fib6_rules_ops);
 	goto out;
 }
 
 void fib6_rules_cleanup(void)
 {
-	fib_rules_unregister(&fib6_rules_ops);
+	fib_rules_unregister(fib6_rules_ops);
+	kfree(fib6_rules_ops);
 }

-- 

  parent reply	other threads:[~2008-01-25 17:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25 16:50 [patch 00/11][NETNS][IPV6] make a subset of the routing per namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 01/11][NETNS][IPV6] ip6_fib - dynamically allocate the tables Daniel Lezcano
2008-01-25 16:50 ` [patch 02/11][NETNS][IPV6] ip6_fib - make the tables per namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 03/11][NETNS][IPV6] ip6_fib - make fib6_clean_all " Daniel Lezcano
2008-01-25 16:50 ` [patch 04/11][NETNS][IPV6] ip6_fib - pass the network namespace parameter to timer callback Daniel Lezcano
2008-01-25 16:50 ` [patch 05/11][NETNS][IPV6] ip6_fib - dynamically allocate the gc_timer Daniel Lezcano
2008-01-25 16:50 ` [patch 06/11][NETNS][IPV6] ip6_fib - make the ip6 fib gc timer per network namespace Daniel Lezcano
2008-01-25 16:50 ` [patch 07/11][NETNS][IPV6] make fib6_clean_node to use the " Daniel Lezcano
2008-01-25 16:50 ` Daniel Lezcano [this message]
2008-01-25 16:50 ` [patch 09/11][NETNS][IPV6] fib6_rules: make per " Daniel Lezcano
2008-01-25 16:50 ` [patch 10/11][NETNS][IPV6] rt6_stats - dynamically allocate the rt6_stats Daniel Lezcano
2008-01-25 16:50 ` [patch 11/11][NETNS][IPV6] rt6_stats - make rt6_stats per namespace Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080125170818.796719655@localhost.localdomain \
    --to=dlezcano@fr.ibm.com \
    --cc=benjamin.thery@bull.net \
    --cc=davem@davemloft.net \
    --cc=den@openvz.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).