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>
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,
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,
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,
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,
};
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,
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,
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,
#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)),
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,
/* 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,
}
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();
/* 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 */