Skip to content

Commit

Permalink
net/802: add __rcu annotations
Browse files Browse the repository at this point in the history
(struct net_device)->garp_port is rcu protected :
(struct garp_port)->applicants is rcu protected :

add __rcu annotation and proper rcu primitives.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Oct 25, 2010
1 parent 198caec commit 3cc77ec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ struct net_device {
struct pcpu_dstats __percpu *dstats; /* dummy stats */
};
/* GARP */
struct garp_port *garp_port;
struct garp_port __rcu *garp_port;

/* class/net/name entry */
struct device dev;
Expand Down
2 changes: 1 addition & 1 deletion include/net/garp.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct garp_applicant {
};

struct garp_port {
struct garp_applicant *applicants[GARP_APPLICATION_MAX + 1];
struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1];
};

extern int garp_register_application(struct garp_application *app);
Expand Down
18 changes: 9 additions & 9 deletions net/802/garp.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ int garp_request_join(const struct net_device *dev,
const struct garp_application *appl,
const void *data, u8 len, u8 type)
{
struct garp_port *port = dev->garp_port;
struct garp_applicant *app = port->applicants[appl->type];
struct garp_port *port = rtnl_dereference(dev->garp_port);
struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]);
struct garp_attr *attr;

spin_lock_bh(&app->lock);
Expand All @@ -366,8 +366,8 @@ void garp_request_leave(const struct net_device *dev,
const struct garp_application *appl,
const void *data, u8 len, u8 type)
{
struct garp_port *port = dev->garp_port;
struct garp_applicant *app = port->applicants[appl->type];
struct garp_port *port = rtnl_dereference(dev->garp_port);
struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]);
struct garp_attr *attr;

spin_lock_bh(&app->lock);
Expand Down Expand Up @@ -546,11 +546,11 @@ static int garp_init_port(struct net_device *dev)

static void garp_release_port(struct net_device *dev)
{
struct garp_port *port = dev->garp_port;
struct garp_port *port = rtnl_dereference(dev->garp_port);
unsigned int i;

for (i = 0; i <= GARP_APPLICATION_MAX; i++) {
if (port->applicants[i])
if (rtnl_dereference(port->applicants[i]))
return;
}
rcu_assign_pointer(dev->garp_port, NULL);
Expand All @@ -565,7 +565,7 @@ int garp_init_applicant(struct net_device *dev, struct garp_application *appl)

ASSERT_RTNL();

if (!dev->garp_port) {
if (!rtnl_dereference(dev->garp_port)) {
err = garp_init_port(dev);
if (err < 0)
goto err1;
Expand Down Expand Up @@ -601,8 +601,8 @@ EXPORT_SYMBOL_GPL(garp_init_applicant);

void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl)
{
struct garp_port *port = dev->garp_port;
struct garp_applicant *app = port->applicants[appl->type];
struct garp_port *port = rtnl_dereference(dev->garp_port);
struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]);

ASSERT_RTNL();

Expand Down
4 changes: 2 additions & 2 deletions net/802/stp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#define GARP_ADDR_MAX 0x2F
#define GARP_ADDR_RANGE (GARP_ADDR_MAX - GARP_ADDR_MIN)

static const struct stp_proto *garp_protos[GARP_ADDR_RANGE + 1] __read_mostly;
static const struct stp_proto *stp_proto __read_mostly;
static const struct stp_proto __rcu *garp_protos[GARP_ADDR_RANGE + 1] __read_mostly;
static const struct stp_proto __rcu *stp_proto __read_mostly;

static struct llc_sap *sap __read_mostly;
static unsigned int sap_registered;
Expand Down

0 comments on commit 3cc77ec

Please sign in to comment.