Skip to content

Commit

Permalink
KLIPS: Support kernels 4.14+ with renamed dev->priv_destructor
Browse files Browse the repository at this point in the history
Patch based on #148
which was written by Pierre-A3i
  • Loading branch information
letoams committed Dec 11, 2017
1 parent 6d9363e commit e859478
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions linux/include/libreswan/ipsec_kversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,5 +584,9 @@ typedef struct ctl_table ctl_table;
# define HAS_AHASH
#endif

#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 1, 14)
# define HAS_PRIV_DESTRUCTOR
#endif

#endif /* _LIBRESWAN_KVERSIONS_H */

5 changes: 5 additions & 0 deletions linux/net/ipsec/ipsec_mast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* IPSEC MAST code.
* Copyright (C) 2005 Michael Richardson <mcr@xelerance.com>
* Copyright (C) 2012 Paul Wouters <paul@libreswan.org>
* Copyright (C) 2017 Paul Wouters <pwouters@redhat.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand Down Expand Up @@ -891,7 +892,11 @@ int ipsec_mast_probe(struct net_device *dev)
dev->neigh_setup = ipsec_mast_neigh_setup_dev;
#endif
#ifdef ipsec_alloc_netdev
# ifdef HAS_PRIV_DESTRUCTOR
dev->priv_destructor = free_netdev;
# else
dev->destructor = free_netdev;
# endif
#endif

#ifndef ipsec_alloc_netdev
Expand Down
4 changes: 4 additions & 0 deletions linux/net/ipsec/ipsec_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,11 @@ int ipsec_tunnel_init(struct net_device *dev)
dev->name ? dev->name : "NULL");

#ifdef ipsec_alloc_netdev
# ifdef HAS_PRIV_DESTRUCTOR
dev->priv_destructor = free_netdev;
# else
dev->destructor = free_netdev;
# endif
#endif

#ifndef HAVE_NETDEV_PRIV
Expand Down
21 changes: 20 additions & 1 deletion linux/net/ipsec/sysctl_net_ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ static ctl_table ipsec_table[] = {
.mode = 0644,
.child = NULL,
.proc_handler = &proc_dointvec, },
# ifdef HAS_PRIV_DESTRUCTOR
{ }
# else
{ 0 }
# endif
#else
{ NET_IPSEC_ICMP, "icmp", &sysctl_ipsec_icmp,
sizeof(int), 0644, NULL, .proc_handler = &proc_dointvec },
Expand All @@ -297,7 +301,11 @@ static ctl_table ipsec_table[] = {
sizeof(int), 0644, NULL, .proc_handler = &proc_dointvec },
{ NET_IPSEC_TOS, "tos", &sysctl_ipsec_tos,
sizeof(int), 0644, NULL, .proc_handler = &proc_dointvec },
# ifdef HAS_PRIV_DESTRUCTOR
{ }
# else
{ 0 }
# endif
#endif
};

Expand All @@ -310,10 +318,13 @@ static ctl_table ipsec_net_table[] = {
.mode = 0555,
.child = ipsec_table,
.proc_handler = NULL, },
# ifdef HAS_PRIV_DESTRUCTOR
{ }
# else
{ 0 }
# endif
#else
{ NET_IPSEC, "ipsec", NULL, 0, 0555, ipsec_table },
{ 0 }
#endif
};

Expand All @@ -326,10 +337,18 @@ static ctl_table ipsec_root_table[] = {
.mode = 0555,
.child = ipsec_net_table,
.proc_handler = NULL, },
# ifdef HAS_PRIV_DESTRUCTOR
{ }
# else
{ 0 }
# endif
#else
{ CTL_NET, "net", NULL, 0, 0555, ipsec_net_table },
# ifdef HAS_PRIV_DESTRUCTOR
{ }
# else
{ 0 }
# endif
#endif
};

Expand Down

0 comments on commit e859478

Please sign in to comment.