datapath: Constify ops structures.
authorJesse Gross <jesse@nicira.com>
Wed, 24 Nov 2010 06:08:27 +0000 (22:08 -0800)
committerJesse Gross <jesse@nicira.com>
Fri, 3 Dec 2010 01:10:16 +0000 (17:10 -0800)
vport_ops, tunnel_ops, and ethtool_ops should not change at runtime.
Therefore, mark them as const to keep them out of the hotpath and to
prevent them from getting trampled.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/vport-capwap.c
datapath/vport-gre.c
datapath/vport-internal_dev.c
datapath/vport-netdev.c
datapath/vport-patch.c
datapath/vport.c
datapath/vport.h

index bf1465f..f732657 100644 (file)
@@ -212,7 +212,7 @@ out:
        return 0;
 }
 
-struct tnl_ops capwap_tnl_ops = {
+const struct tnl_ops capwap_tnl_ops = {
        .tunnel_type    = TNL_T_PROTO_CAPWAP,
        .ipproto        = IPPROTO_UDP,
        .hdr_len        = capwap_hdr_len,
@@ -644,7 +644,7 @@ static void capwap_frag_expire(unsigned long ifq)
        inet_frag_put(&fq->ifq, &frag_state);
 }
 
-struct vport_ops capwap_vport_ops = {
+const struct vport_ops capwap_vport_ops = {
        .type           = "capwap",
        .flags          = VPORT_F_GEN_STATS,
        .init           = capwap_init,
index be8fb53..fcf1ede 100644 (file)
@@ -332,7 +332,7 @@ error:
        return 0;
 }
 
-struct tnl_ops gre_tnl_ops = {
+const struct tnl_ops gre_tnl_ops = {
        .tunnel_type    = TNL_T_PROTO_GRE,
        .ipproto        = IPPROTO_GRE,
        .hdr_len        = gre_hdr_len,
@@ -345,7 +345,7 @@ static struct vport *gre_create(const char *name, const void __user *config)
        return tnl_create(name, config, &gre_vport_ops, &gre_tnl_ops);
 }
 
-static struct net_protocol gre_protocol_handlers = {
+static const struct net_protocol gre_protocol_handlers = {
        .handler        =       gre_rcv,
        .err_handler    =       gre_err,
 };
@@ -366,7 +366,7 @@ static void gre_exit(void)
        inet_del_protocol(&gre_protocol_handlers, IPPROTO_GRE);
 }
 
-struct vport_ops gre_vport_ops = {
+const struct vport_ops gre_vport_ops = {
        .type           = "gre",
        .flags          = VPORT_F_GEN_STATS | VPORT_F_TUN_ID,
        .init           = gre_init,
index 6d610fd..ec0052c 100644 (file)
@@ -108,7 +108,7 @@ static void internal_dev_getinfo(struct net_device *netdev,
                sprintf(info->bus_info, "%d.%d", dp_port->dp->dp_idx, dp_port->port_no);
 }
 
-static struct ethtool_ops internal_dev_ethtool_ops = {
+static const struct ethtool_ops internal_dev_ethtool_ops = {
        .get_drvinfo    = internal_dev_getinfo,
        .get_link       = ethtool_op_get_link,
        .get_sg         = ethtool_op_get_sg,
@@ -278,7 +278,7 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb)
        return len;
 }
 
-struct vport_ops internal_vport_ops = {
+const struct vport_ops internal_vport_ops = {
        .type           = "internal",
        .flags          = VPORT_F_REQUIRED | VPORT_F_GEN_STATS | VPORT_F_FLOW,
        .create         = internal_dev_create,
index c643696..11421bf 100644 (file)
@@ -299,7 +299,7 @@ struct vport *netdev_get_vport(struct net_device *dev)
 #endif
 }
 
-struct vport_ops netdev_vport_ops = {
+const struct vport_ops netdev_vport_ops = {
        .type           = "netdev",
        .flags          = (VPORT_F_REQUIRED |
                          (USE_VPORT_STATS ? VPORT_F_GEN_STATS : 0)),
index 62fd71f..81fa61b 100644 (file)
@@ -265,7 +265,7 @@ static int patch_send(struct vport *vport, struct sk_buff *skb)
        return skb_len;
 }
 
-struct vport_ops patch_vport_ops = {
+const struct vport_ops patch_vport_ops = {
        .type           = "patch",
        .flags          = VPORT_F_GEN_STATS,
        .init           = patch_init,
index c68e181..fdbf522 100644 (file)
@@ -25,7 +25,7 @@
 
 /* List of statically compiled vport implementations.  Don't forget to also
  * add yours to the list at the bottom of vport.h. */
-static struct vport_ops *base_vport_ops_list[] = {
+static const struct vport_ops *base_vport_ops_list[] = {
        &netdev_vport_ops,
        &internal_vport_ops,
        &patch_vport_ops,
@@ -113,7 +113,7 @@ int vport_init(void)
        }
 
        for (i = 0; i < ARRAY_SIZE(base_vport_ops_list); i++) {
-               struct vport_ops *new_ops = base_vport_ops_list[i];
+               const struct vport_ops *new_ops = base_vport_ops_list[i];
 
                if (new_ops->init)
                        err = new_ops->init();
index 641353c..bacefa8 100644 (file)
@@ -239,10 +239,10 @@ void vport_record_error(struct vport *, enum vport_err_type err_type);
 
 /* List of statically compiled vport implementations.  Don't forget to also
  * add yours to the list at the top of vport.c. */
-extern struct vport_ops netdev_vport_ops;
-extern struct vport_ops internal_vport_ops;
-extern struct vport_ops patch_vport_ops;
-extern struct vport_ops gre_vport_ops;
-extern struct vport_ops capwap_vport_ops;
+extern const struct vport_ops netdev_vport_ops;
+extern const struct vport_ops internal_vport_ops;
+extern const struct vport_ops patch_vport_ops;
+extern const struct vport_ops gre_vport_ops;
+extern const struct vport_ops capwap_vport_ops;
 
 #endif /* vport.h */