summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2019-12-24 14:50:04 +0300
committerDmitry Kozlov <xeb@mail.ru>2019-12-24 14:50:04 +0300
commit4d837cc3bd92493732f2c598560e9e83c82f9b9e (patch)
tree5484fbf0fc3dcedd82bd601a7a3f7458c25dc932 /drivers
parentfe7c3a4b74b9f1ed57d22316069602acd4794265 (diff)
downloadaccel-ppp-4d837cc3bd92493732f2c598560e9e83c82f9b9e.tar.gz
accel-ppp-4d837cc3bd92493732f2c598560e9e83c82f9b9e.zip
ipoe,vlan_mon: add support for kernels 5.2+
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ipoe/ipoe.c58
-rw-r--r--drivers/vlan_mon/vlan_mon.c37
2 files changed, 74 insertions, 21 deletions
diff --git a/drivers/ipoe/ipoe.c b/drivers/ipoe/ipoe.c
index f3acb3f5..6ac6d77a 100644
--- a/drivers/ipoe/ipoe.c
+++ b/drivers/ipoe/ipoe.c
@@ -174,6 +174,10 @@ static struct genl_multicast_group ipoe_nl_mcg;
#define NETIF_F_HW_VLAN_FILTER NETIF_F_HW_VLAN_CTAG_FILTER
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+#define nla_nest_start_noflag(skb, attr) nla_nest_start(skb, attr)
+#endif
+
static inline int hash_addr(__be32 addr)
{
#ifdef __LITTLE_ENDIAN
@@ -255,8 +259,13 @@ static int check_nat_required(struct sk_buff *skb, struct net_device *link)
if (IS_ERR(rt))
return 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
if (rt->rt_gateway || (rt->dst.dev != link && rt->dst.dev != skb->dev))
r = 1;
+#else
+ if (rt->rt_gw4 || (rt->dst.dev != link && rt->dst.dev != skb->dev))
+ r = 1;
+#endif
ip_rt_put(rt);
@@ -616,7 +625,7 @@ static void ipoe_process_queue(struct work_struct *w)
}
if (report_skb) {
- ns = nla_nest_start(report_skb, id++);
+ ns = nla_nest_start_noflag(report_skb, id++);
if (!ns)
goto nl_err;
@@ -1729,7 +1738,7 @@ static int ipoe_nl_cmd_del_net(struct sk_buff *skb, struct genl_info *info)
return 0;
}
-static struct nla_policy ipoe_nl_policy[IPOE_ATTR_MAX + 1] = {
+static const struct nla_policy ipoe_nl_policy[IPOE_ATTR_MAX + 1] = {
[IPOE_ATTR_NONE] = { .type = NLA_UNSPEC, },
[IPOE_ATTR_ADDR] = { .type = NLA_U32, },
[IPOE_ATTR_PEER_ADDR] = { .type = NLA_U32, },
@@ -1741,71 +1750,93 @@ static struct nla_policy ipoe_nl_policy[IPOE_ATTR_MAX + 1] = {
[IPOE_ATTR_LINK_IFINDEX]= { .type = NLA_U32, },
};
-static struct genl_ops ipoe_nl_ops[] = {
+static const struct genl_ops ipoe_nl_ops[] = {
{
.cmd = IPOE_CMD_NOOP,
.doit = ipoe_nl_cmd_noop,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
.policy = ipoe_nl_policy,
+#endif
/* can be retrieved by unprivileged users */
},
{
.cmd = IPOE_CMD_CREATE,
.doit = ipoe_nl_cmd_create,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DELETE,
.doit = ipoe_nl_cmd_delete,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_MODIFY,
.doit = ipoe_nl_cmd_modify,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_GET,
.dumpit = ipoe_nl_cmd_dump_sessions,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
.policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_ADD_IF,
.doit = ipoe_nl_cmd_add_interface,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DEL_IF,
.doit = ipoe_nl_cmd_del_interface,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_ADD_EXCLUDE,
.doit = ipoe_nl_cmd_add_exclude,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DEL_EXCLUDE,
.doit = ipoe_nl_cmd_del_exclude,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_ADD_NET,
.doit = ipoe_nl_cmd_add_net,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DEL_NET,
.doit = ipoe_nl_cmd_del_net,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
};
@@ -1834,6 +1865,9 @@ static struct genl_family ipoe_nl_family = {
.mcgrps = ipoe_nl_mcgs,
.n_mcgrps = ARRAY_SIZE(ipoe_nl_mcgs),
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
};
static const struct net_device_ops ipoe_netdev_ops = {
diff --git a/drivers/vlan_mon/vlan_mon.c b/drivers/vlan_mon/vlan_mon.c
index b6476d4c..271f2ff1 100644
--- a/drivers/vlan_mon/vlan_mon.c
+++ b/drivers/vlan_mon/vlan_mon.c
@@ -43,6 +43,10 @@
#define vlan_tx_tag_present(skb) skb_vlan_tag_present(skb)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+#define nla_nest_start_noflag(skb, attr) nla_nest_start(skb, attr)
+#endif
+
struct vlan_dev {
unsigned int magic;
int ifindex;
@@ -198,13 +202,13 @@ static void vlan_do_notify(struct work_struct *w)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) && RHEL_MAJOR < 7
header = genlmsg_put(report_skb, 0, vlan_mon_nl_mcg.id, &vlan_mon_nl_family, 0, VLAN_MON_NOTIFY);
#else
- header = genlmsg_put(report_skb, 0, vlan_mon_nl_family.mcgrp_offset, &vlan_mon_nl_family, 0, VLAN_MON_NOTIFY);
+ header = genlmsg_put(report_skb, 0, 0, &vlan_mon_nl_family, 0, VLAN_MON_NOTIFY);
#endif
}
//pr_info("notify %i vlan %i\n", id, n->vid);
- ns = nla_nest_start(report_skb, id++);
+ ns = nla_nest_start_noflag(report_skb, id++);
if (!ns)
goto nl_err;
@@ -616,7 +620,7 @@ static int vlan_mon_nl_cmd_check_busy(struct sk_buff *skb, struct genl_info *inf
return ret;
}
-static struct nla_policy vlan_mon_nl_policy[VLAN_MON_ATTR_MAX + 1] = {
+static const struct nla_policy vlan_mon_nl_policy[VLAN_MON_ATTR_MAX + 1] = {
[VLAN_MON_ATTR_NONE] = { .type = NLA_UNSPEC, },
[VLAN_MON_ATTR_VLAN_MASK] = { .type = NLA_BINARY, .len = 4096/8 },
[VLAN_MON_ATTR_PROTO] = { .type = NLA_U16, },
@@ -624,42 +628,54 @@ static struct nla_policy vlan_mon_nl_policy[VLAN_MON_ATTR_MAX + 1] = {
[VLAN_MON_ATTR_VID] = { .type = NLA_U16, },
};
-static struct genl_ops vlan_mon_nl_ops[] = {
+static const struct genl_ops vlan_mon_nl_ops[] = {
{
.cmd = VLAN_MON_CMD_NOOP,
.doit = vlan_mon_nl_cmd_noop,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
.policy = vlan_mon_nl_policy,
+#endif
/* can be retrieved by unprivileged users */
},
{
.cmd = VLAN_MON_CMD_ADD,
.doit = vlan_mon_nl_cmd_add_vlan_mon,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_ADD_VID,
.doit = vlan_mon_nl_cmd_add_vlan_mon_vid,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_DEL,
.doit = vlan_mon_nl_cmd_del_vlan_mon,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_CHECK_BUSY,
.doit = vlan_mon_nl_cmd_check_busy,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_DEL_VID,
.doit = vlan_mon_nl_cmd_del_vlan_mon_vid,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
};
@@ -688,6 +704,9 @@ static struct genl_family vlan_mon_nl_family = {
.mcgrps = vlan_mon_nl_mcgs,
.n_mcgrps = ARRAY_SIZE(vlan_mon_nl_mcgs),
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
};
static struct packet_type vlan_pt __read_mostly = {