summaryrefslogtreecommitdiffstats
path: root/net/openvswitch/datapath.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r--net/openvswitch/datapath.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 449e0776a2c0..6f5e1dd3be2d 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -61,11 +61,11 @@
61 61
62int ovs_net_id __read_mostly; 62int ovs_net_id __read_mostly;
63 63
64static void ovs_notify(struct sk_buff *skb, struct genl_info *info, 64static void ovs_notify(struct genl_family *family,
65 struct genl_multicast_group *grp) 65 struct sk_buff *skb, struct genl_info *info)
66{ 66{
67 genl_notify(skb, genl_info_net(info), info->snd_portid, 67 genl_notify(family, skb, genl_info_net(info), info->snd_portid,
68 grp->id, info->nlhdr, GFP_KERNEL); 68 0, info->nlhdr, GFP_KERNEL);
69} 69}
70 70
71/** 71/**
@@ -557,7 +557,7 @@ static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
557 [OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED }, 557 [OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
558}; 558};
559 559
560static struct genl_ops dp_packet_genl_ops[] = { 560static const struct genl_ops dp_packet_genl_ops[] = {
561 { .cmd = OVS_PACKET_CMD_EXECUTE, 561 { .cmd = OVS_PACKET_CMD_EXECUTE,
562 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 562 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
563 .policy = packet_policy, 563 .policy = packet_policy,
@@ -877,10 +877,10 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
877 ovs_unlock(); 877 ovs_unlock();
878 878
879 if (!IS_ERR(reply)) 879 if (!IS_ERR(reply))
880 ovs_notify(reply, info, &ovs_dp_flow_multicast_group); 880 ovs_notify(&dp_flow_genl_family, reply, info);
881 else 881 else
882 netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 882 genl_set_err(&dp_flow_genl_family, sock_net(skb->sk), 0,
883 ovs_dp_flow_multicast_group.id, PTR_ERR(reply)); 883 0, PTR_ERR(reply));
884 return 0; 884 return 0;
885 885
886err_flow_free: 886err_flow_free:
@@ -990,7 +990,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
990 ovs_flow_free(flow, true); 990 ovs_flow_free(flow, true);
991 ovs_unlock(); 991 ovs_unlock();
992 992
993 ovs_notify(reply, info, &ovs_dp_flow_multicast_group); 993 ovs_notify(&dp_flow_genl_family, reply, info);
994 return 0; 994 return 0;
995unlock: 995unlock:
996 ovs_unlock(); 996 ovs_unlock();
@@ -1034,7 +1034,7 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1034 return skb->len; 1034 return skb->len;
1035} 1035}
1036 1036
1037static struct genl_ops dp_flow_genl_ops[] = { 1037static const struct genl_ops dp_flow_genl_ops[] = {
1038 { .cmd = OVS_FLOW_CMD_NEW, 1038 { .cmd = OVS_FLOW_CMD_NEW,
1039 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1039 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1040 .policy = flow_policy, 1040 .policy = flow_policy,
@@ -1243,7 +1243,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
1243 1243
1244 ovs_unlock(); 1244 ovs_unlock();
1245 1245
1246 ovs_notify(reply, info, &ovs_dp_datapath_multicast_group); 1246 ovs_notify(&dp_datapath_genl_family, reply, info);
1247 return 0; 1247 return 0;
1248 1248
1249err_destroy_local_port: 1249err_destroy_local_port:
@@ -1308,7 +1308,7 @@ static int ovs_dp_cmd_del(struct sk_buff *skb, struct genl_info *info)
1308 __dp_destroy(dp); 1308 __dp_destroy(dp);
1309 ovs_unlock(); 1309 ovs_unlock();
1310 1310
1311 ovs_notify(reply, info, &ovs_dp_datapath_multicast_group); 1311 ovs_notify(&dp_datapath_genl_family, reply, info);
1312 1312
1313 return 0; 1313 return 0;
1314unlock: 1314unlock:
@@ -1332,14 +1332,14 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info)
1332 info->snd_seq, OVS_DP_CMD_NEW); 1332 info->snd_seq, OVS_DP_CMD_NEW);
1333 if (IS_ERR(reply)) { 1333 if (IS_ERR(reply)) {
1334 err = PTR_ERR(reply); 1334 err = PTR_ERR(reply);
1335 netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 1335 genl_set_err(&dp_datapath_genl_family, sock_net(skb->sk), 0,
1336 ovs_dp_datapath_multicast_group.id, err); 1336 0, err);
1337 err = 0; 1337 err = 0;
1338 goto unlock; 1338 goto unlock;
1339 } 1339 }
1340 1340
1341 ovs_unlock(); 1341 ovs_unlock();
1342 ovs_notify(reply, info, &ovs_dp_datapath_multicast_group); 1342 ovs_notify(&dp_datapath_genl_family, reply, info);
1343 1343
1344 return 0; 1344 return 0;
1345unlock: 1345unlock:
@@ -1398,7 +1398,7 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1398 return skb->len; 1398 return skb->len;
1399} 1399}
1400 1400
1401static struct genl_ops dp_datapath_genl_ops[] = { 1401static const struct genl_ops dp_datapath_genl_ops[] = {
1402 { .cmd = OVS_DP_CMD_NEW, 1402 { .cmd = OVS_DP_CMD_NEW,
1403 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1403 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1404 .policy = datapath_policy, 1404 .policy = datapath_policy,
@@ -1431,7 +1431,7 @@ static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
1431 [OVS_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED }, 1431 [OVS_VPORT_ATTR_OPTIONS] = { .type = NLA_NESTED },
1432}; 1432};
1433 1433
1434static struct genl_family dp_vport_genl_family = { 1434struct genl_family dp_vport_genl_family = {
1435 .id = GENL_ID_GENERATE, 1435 .id = GENL_ID_GENERATE,
1436 .hdrsize = sizeof(struct ovs_header), 1436 .hdrsize = sizeof(struct ovs_header),
1437 .name = OVS_VPORT_FAMILY, 1437 .name = OVS_VPORT_FAMILY,
@@ -1601,7 +1601,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
1601 goto exit_unlock; 1601 goto exit_unlock;
1602 } 1602 }
1603 1603
1604 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 1604 ovs_notify(&dp_vport_genl_family, reply, info);
1605 1605
1606exit_unlock: 1606exit_unlock:
1607 ovs_unlock(); 1607 ovs_unlock();
@@ -1648,7 +1648,7 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
1648 BUG_ON(err < 0); 1648 BUG_ON(err < 0);
1649 1649
1650 ovs_unlock(); 1650 ovs_unlock();
1651 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 1651 ovs_notify(&dp_vport_genl_family, reply, info);
1652 return 0; 1652 return 0;
1653 1653
1654exit_free: 1654exit_free:
@@ -1685,7 +1685,7 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info)
1685 err = 0; 1685 err = 0;
1686 ovs_dp_detach_port(vport); 1686 ovs_dp_detach_port(vport);
1687 1687
1688 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 1688 ovs_notify(&dp_vport_genl_family, reply, info);
1689 1689
1690exit_unlock: 1690exit_unlock:
1691 ovs_unlock(); 1691 ovs_unlock();
@@ -1759,7 +1759,7 @@ out:
1759 return skb->len; 1759 return skb->len;
1760} 1760}
1761 1761
1762static struct genl_ops dp_vport_genl_ops[] = { 1762static const struct genl_ops dp_vport_genl_ops[] = {
1763 { .cmd = OVS_VPORT_CMD_NEW, 1763 { .cmd = OVS_VPORT_CMD_NEW,
1764 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1764 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1765 .policy = vport_policy, 1765 .policy = vport_policy,
@@ -1785,9 +1785,9 @@ static struct genl_ops dp_vport_genl_ops[] = {
1785 1785
1786struct genl_family_and_ops { 1786struct genl_family_and_ops {
1787 struct genl_family *family; 1787 struct genl_family *family;
1788 struct genl_ops *ops; 1788 const struct genl_ops *ops;
1789 int n_ops; 1789 int n_ops;
1790 struct genl_multicast_group *group; 1790 const struct genl_multicast_group *group;
1791}; 1791};
1792 1792
1793static const struct genl_family_and_ops dp_genl_families[] = { 1793static const struct genl_family_and_ops dp_genl_families[] = {
@@ -1823,17 +1823,14 @@ static int dp_register_genl(void)
1823 for (i = 0; i < ARRAY_SIZE(dp_genl_families); i++) { 1823 for (i = 0; i < ARRAY_SIZE(dp_genl_families); i++) {
1824 const struct genl_family_and_ops *f = &dp_genl_families[i]; 1824 const struct genl_family_and_ops *f = &dp_genl_families[i];
1825 1825
1826 err = genl_register_family_with_ops(f->family, f->ops, 1826 f->family->ops = f->ops;
1827 f->n_ops); 1827 f->family->n_ops = f->n_ops;
1828 f->family->mcgrps = f->group;
1829 f->family->n_mcgrps = f->group ? 1 : 0;
1830 err = genl_register_family(f->family);
1828 if (err) 1831 if (err)
1829 goto error; 1832 goto error;
1830 n_registered++; 1833 n_registered++;
1831
1832 if (f->group) {
1833 err = genl_register_mc_group(f->family, f->group);
1834 if (err)
1835 goto error;
1836 }
1837 } 1834 }
1838 1835
1839 return 0; 1836 return 0;