From: Jesse Gross Date: Wed, 24 Nov 2010 06:08:27 +0000 (-0800) Subject: datapath: Constify ops structures. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b279fccf5bd8c5addfb8e73b04103405b6a8237e;p=openvswitch datapath: Constify ops structures. 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 Acked-by: Ben Pfaff --- diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c index bf1465fc..f732657f 100644 --- a/datapath/vport-capwap.c +++ b/datapath/vport-capwap.c @@ -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, diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c index be8fb534..fcf1edea 100644 --- a/datapath/vport-gre.c +++ b/datapath/vport-gre.c @@ -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, diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c index 6d610fda..ec0052ca 100644 --- a/datapath/vport-internal_dev.c +++ b/datapath/vport-internal_dev.c @@ -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, diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c index c643696f..11421bf7 100644 --- a/datapath/vport-netdev.c +++ b/datapath/vport-netdev.c @@ -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)), diff --git a/datapath/vport-patch.c b/datapath/vport-patch.c index 62fd71f7..81fa61b1 100644 --- a/datapath/vport-patch.c +++ b/datapath/vport-patch.c @@ -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, diff --git a/datapath/vport.c b/datapath/vport.c index c68e1814..fdbf522e 100644 --- a/datapath/vport.c +++ b/datapath/vport.c @@ -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(); diff --git a/datapath/vport.h b/datapath/vport.h index 641353cd..bacefa84 100644 --- a/datapath/vport.h +++ b/datapath/vport.h @@ -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 */