Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/802: add __rcu annotations

(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 <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
3cc77ec7 198caeca

+13 -13
+1 -1
include/linux/netdevice.h
··· 1072 1072 struct pcpu_dstats __percpu *dstats; /* dummy stats */ 1073 1073 }; 1074 1074 /* GARP */ 1075 - struct garp_port *garp_port; 1075 + struct garp_port __rcu *garp_port; 1076 1076 1077 1077 /* class/net/name entry */ 1078 1078 struct device dev;
+1 -1
include/net/garp.h
··· 107 107 }; 108 108 109 109 struct garp_port { 110 - struct garp_applicant *applicants[GARP_APPLICATION_MAX + 1]; 110 + struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1]; 111 111 }; 112 112 113 113 extern int garp_register_application(struct garp_application *app);
+9 -9
net/802/garp.c
··· 346 346 const struct garp_application *appl, 347 347 const void *data, u8 len, u8 type) 348 348 { 349 - struct garp_port *port = dev->garp_port; 350 - struct garp_applicant *app = port->applicants[appl->type]; 349 + struct garp_port *port = rtnl_dereference(dev->garp_port); 350 + struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]); 351 351 struct garp_attr *attr; 352 352 353 353 spin_lock_bh(&app->lock); ··· 366 366 const struct garp_application *appl, 367 367 const void *data, u8 len, u8 type) 368 368 { 369 - struct garp_port *port = dev->garp_port; 370 - struct garp_applicant *app = port->applicants[appl->type]; 369 + struct garp_port *port = rtnl_dereference(dev->garp_port); 370 + struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]); 371 371 struct garp_attr *attr; 372 372 373 373 spin_lock_bh(&app->lock); ··· 546 546 547 547 static void garp_release_port(struct net_device *dev) 548 548 { 549 - struct garp_port *port = dev->garp_port; 549 + struct garp_port *port = rtnl_dereference(dev->garp_port); 550 550 unsigned int i; 551 551 552 552 for (i = 0; i <= GARP_APPLICATION_MAX; i++) { 553 - if (port->applicants[i]) 553 + if (rtnl_dereference(port->applicants[i])) 554 554 return; 555 555 } 556 556 rcu_assign_pointer(dev->garp_port, NULL); ··· 565 565 566 566 ASSERT_RTNL(); 567 567 568 - if (!dev->garp_port) { 568 + if (!rtnl_dereference(dev->garp_port)) { 569 569 err = garp_init_port(dev); 570 570 if (err < 0) 571 571 goto err1; ··· 601 601 602 602 void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl) 603 603 { 604 - struct garp_port *port = dev->garp_port; 605 - struct garp_applicant *app = port->applicants[appl->type]; 604 + struct garp_port *port = rtnl_dereference(dev->garp_port); 605 + struct garp_applicant *app = rtnl_dereference(port->applicants[appl->type]); 606 606 607 607 ASSERT_RTNL(); 608 608
+2 -2
net/802/stp.c
··· 21 21 #define GARP_ADDR_MAX 0x2F 22 22 #define GARP_ADDR_RANGE (GARP_ADDR_MAX - GARP_ADDR_MIN) 23 23 24 - static const struct stp_proto *garp_protos[GARP_ADDR_RANGE + 1] __read_mostly; 25 - static const struct stp_proto *stp_proto __read_mostly; 24 + static const struct stp_proto __rcu *garp_protos[GARP_ADDR_RANGE + 1] __read_mostly; 25 + static const struct stp_proto __rcu *stp_proto __read_mostly; 26 26 27 27 static struct llc_sap *sap __read_mostly; 28 28 static unsigned int sap_registered;