diff mbox series

[ovs-dev] datapath: make generic netlink group const

Message ID 1574720444-31064-1-git-send-email-gvrose8192@gmail.com
State Accepted
Commit e515e66a1900feffd4af08c2596fb8d59b07ddd6
Headers show
Series [ovs-dev] datapath: make generic netlink group const | expand

Commit Message

Gregory Rose Nov. 25, 2019, 10:20 p.m. UTC
Upstream commit:
    commit 48e48a70c08a8a68f8697f8b30cb83775bda8001
    Author: stephen hemminger <stephen@networkplumber.org>
    Date:   Wed Jul 16 11:25:52 2014 -0700

    openvswitch: make generic netlink group const

    Generic netlink tables can be const.

    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

The equivalent tables in meter.c and conntrack.c are constified so
it should be safe to do the same for these and will improve
security as well.

Original patch slightly modified for out of tree module.

Passes check-kmod.
Passes Travis.
https://travis-ci.org/gvrose8192/ovs-experimental/builds/616880002

Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
---
 datapath/datapath.c | 21 +++++++++++----------
 datapath/datapath.h |  2 +-
 2 files changed, 12 insertions(+), 11 deletions(-)

Comments

Ben Pfaff Dec. 2, 2019, 10:38 p.m. UTC | #1
On Mon, Nov 25, 2019 at 02:20:44PM -0800, Greg Rose wrote:
> Upstream commit:
>     commit 48e48a70c08a8a68f8697f8b30cb83775bda8001
>     Author: stephen hemminger <stephen@networkplumber.org>
>     Date:   Wed Jul 16 11:25:52 2014 -0700
> 
>     openvswitch: make generic netlink group const
> 
>     Generic netlink tables can be const.
> 
>     Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>     Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> The equivalent tables in meter.c and conntrack.c are constified so
> it should be safe to do the same for these and will improve
> security as well.
> 
> Original patch slightly modified for out of tree module.
> 
> Passes check-kmod.
> Passes Travis.
> https://travis-ci.org/gvrose8192/ovs-experimental/builds/616880002
> 
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Greg Rose <gvrose8192@gmail.com>

Thanks, applied to (OVS) master.
diff mbox series

Patch

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 8a9e54f..853bfb5 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -71,16 +71,16 @@  static struct genl_family dp_datapath_genl_family;
 
 static const struct nla_policy flow_policy[];
 
-static struct genl_multicast_group ovs_dp_flow_multicast_group = {
-	.name = OVS_FLOW_MCGROUP
+static const struct genl_multicast_group ovs_dp_flow_multicast_group = {
+	.name = OVS_FLOW_MCGROUP,
 };
 
-static struct genl_multicast_group ovs_dp_datapath_multicast_group = {
-	.name = OVS_DATAPATH_MCGROUP
+static const struct genl_multicast_group ovs_dp_datapath_multicast_group = {
+	.name = OVS_DATAPATH_MCGROUP,
 };
 
-struct genl_multicast_group ovs_dp_vport_multicast_group = {
-	.name = OVS_VPORT_MCGROUP
+const struct genl_multicast_group ovs_dp_vport_multicast_group = {
+	.name = OVS_VPORT_MCGROUP,
 };
 
 /* Check if need to build a reply message.
@@ -93,7 +93,8 @@  static bool ovs_must_notify(struct genl_family *family, struct genl_info *info,
 	       genl_has_listeners(family, genl_info_net(info), group);
 }
 
-static void ovs_notify(struct genl_family *family, struct genl_multicast_group *grp,
+static void ovs_notify(struct genl_family *family,
+		       const struct genl_multicast_group *grp,
 		       struct sk_buff *skb, struct genl_info *info)
 {
 	genl_notify(family, skb, info, GROUP_ID(grp), GFP_KERNEL);
@@ -1442,7 +1443,7 @@  static const struct nla_policy flow_policy[OVS_FLOW_ATTR_MAX + 1] = {
 	[OVS_FLOW_ATTR_UFID_FLAGS] = { .type = NLA_U32 },
 };
 
-static struct genl_ops dp_flow_genl_ops[] = {
+static const struct genl_ops dp_flow_genl_ops[] = {
 	{ .cmd = OVS_FLOW_CMD_NEW,
 #ifdef HAVE_GENL_VALIDATE_FLAGS
 	  .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -1846,7 +1847,7 @@  static const struct nla_policy datapath_policy[OVS_DP_ATTR_MAX + 1] = {
 	[OVS_DP_ATTR_USER_FEATURES] = { .type = NLA_U32 },
 };
 
-static struct genl_ops dp_datapath_genl_ops[] = {
+static const struct genl_ops dp_datapath_genl_ops[] = {
 	{ .cmd = OVS_DP_CMD_NEW,
 #ifdef HAVE_GENL_VALIDATE_FLAGS
 	  .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -2303,7 +2304,7 @@  static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
 	[OVS_VPORT_ATTR_NETNSID] = { .type = NLA_S32 },
 };
 
-static struct genl_ops dp_vport_genl_ops[] = {
+static const struct genl_ops dp_vport_genl_ops[] = {
 	{ .cmd = OVS_VPORT_CMD_NEW,
 #ifdef HAVE_GENL_VALIDATE_FLAGS
 	  .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
diff --git a/datapath/datapath.h b/datapath/datapath.h
index ee76662..3bffa1d 100644
--- a/datapath/datapath.h
+++ b/datapath/datapath.h
@@ -237,7 +237,7 @@  static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
 
 extern struct notifier_block ovs_dp_device_notifier;
 extern struct genl_family dp_vport_genl_family;
-extern struct genl_multicast_group ovs_dp_vport_multicast_group;
+extern const struct genl_multicast_group ovs_dp_vport_multicast_group;
 
 void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key);
 void ovs_dp_detach_port(struct vport *);