* [Cocci] [PATCH 0/4] backports: SmPL patch equivalence support
@ 2015-06-06 0:09 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:09 UTC (permalink / raw)
To: cocci
From: "Luis R. Rodriguez" <mcgrof@suse.com>
A long time ago I wrote SmPL <--> patch equivalence proof support
for backports but put that work on hold as I found it could be
useful as a generic tool. Quite a bit of time has passed and I
haven't gotten to that again so just merge this for now. If we want
to generalize it we can do so later.
This goes with an example patch being transformed.
Luis R. Rodriguez (4):
patches: remove bt_sock_stream_recvmsg() and bt_sock_recvmsg() from
ifdefs
patches: change 0054-struct-proto_ops-sig backport strategy
gentree.py: add SmPL patch equivalence proof support
patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
gentree.py | 71 ++++++-
.../network/0054-struct-proto_ops-sig.cocci | 177 +++++++++++++++++
.../0054-struct-proto_ops-sig/bluetooth.patch | 212 ---------------------
.../0054-struct-proto_ops-sig/ieee802154.patch | 79 --------
.../network/0054-struct-proto_ops-sig/nfc.patch | 59 ------
5 files changed, 240 insertions(+), 358 deletions(-)
create mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply [flat|nested] 26+ messages in thread* [PATCH 1/4] patches: remove bt_sock_stream_recvmsg() and bt_sock_recvmsg() from ifdefs
2015-06-06 0:09 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-06 0:09 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:09 UTC (permalink / raw)
To: backports; +Cc: cocci, Luis R. Rodriguez
Both bt_sock_recvmsg() and bt_sock_stream_recvmsg() are used
within bluetooth code but the backport actually required is only
for the struct proto_ops and struct proto sendmsg and recvmsg
callbacks. The bt_sock_recvmsg() and bt_sock_stream_recvmsg()
are not callbacks, they are exported but are used all within
the code we provide and carry.
This will help simplify the network/0054-struct-proto_ops-sig
collateral evolution port to Coccinelle SmPL.
1 3.0.101 [ OK ]
2 3.1.10 [ OK ]
3 3.2.68 [ OK ]
4 3.3.8 [ OK ]
5 3.4.107 [ OK ]
6 3.5.7 [ OK ]
7 3.6.11 [ OK ]
8 3.7.10 [ OK ]
9 3.8.13 [ OK ]
10 3.9.11 [ OK ]
11 3.10.75 [ OK ]
12 3.11.10 [ OK ]
13 3.12.40 [ OK ]
14 3.13.11 [ OK ]
15 3.14.39 [ OK ]
16 3.15.10 [ OK ]
17 3.16.7 [ OK ]
18 3.17.8 [ OK ]
19 3.18.12 [ OK ]
20 3.19.5 [ OK ]
21 4.0.0 [ OK ]
22 4.1-rc1 [ OK ]
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
.../0054-struct-proto_ops-sig/bluetooth.patch | 92 ----------------------
1 file changed, 92 deletions(-)
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
index 614e551..1bd0ced 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
@@ -1,53 +1,3 @@
---- a/include/net/bluetooth/bluetooth.h
-+++ b/include/net/bluetooth/bluetooth.h
-@@ -245,10 +245,17 @@ int bt_sock_register(int proto, const s
- void bt_sock_unregister(int proto);
- void bt_sock_link(struct bt_sock_list *l, struct sock *s);
- void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags);
- int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags);
-+#else
-+int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags);
-+int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags);
-+#endif
- uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
- int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
- int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
---- a/net/bluetooth/af_bluetooth.c
-+++ b/net/bluetooth/af_bluetooth.c
-@@ -210,8 +210,13 @@ struct sock *bt_accept_dequeue(struct so
- }
- EXPORT_SYMBOL(bt_accept_dequeue);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags)
-+#else
-+int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
-@@ -283,8 +288,13 @@ static long bt_sock_data_wait(struct soc
- return timeo;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t size, int flags)
-+#else
-+int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t size, int flags)
-+#endif
- {
- struct sock *sk = sock->sk;
- int err = 0;
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -906,8 +906,13 @@ static void hci_sock_cmsg(struct sock *s
@@ -108,24 +58,6 @@
{
struct sock *sk = sock->sk;
struct l2cap_pinfo *pi = l2cap_pi(sk);
-@@ -1004,9 +1014,17 @@ static int l2cap_sock_recvmsg(struct soc
- release_sock(sk);
-
- if (sock->type == SOCK_STREAM)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- err = bt_sock_stream_recvmsg(sock, msg, len, flags);
-+#else
-+ err = bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
-+#endif
- else
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- err = bt_sock_recvmsg(sock, msg, len, flags);
-+#else
-+ err = bt_sock_recvmsg(iocb, sock, msg, len, flags);
-+#endif
-
- if (pi->chan->mode != L2CAP_MODE_ERTM)
- return err;
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -549,8 +549,13 @@ static int rfcomm_sock_getname(struct so
@@ -156,18 +88,6 @@
{
struct sock *sk = sock->sk;
struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
-@@ -627,7 +637,11 @@ static int rfcomm_sock_recvmsg(struct so
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- len = bt_sock_stream_recvmsg(sock, msg, size, flags);
-+#else
-+ len = bt_sock_stream_recvmsg(iocb, sock, msg, size, flags);
-+#endif
-
- lock_sock(sk);
- if (!(flags & MSG_PEEK) && len > 0)
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -688,8 +688,13 @@ static int sco_sock_getname(struct socke
@@ -198,15 +118,3 @@
{
struct sock *sk = sock->sk;
struct sco_pinfo *pi = sco_pi(sk);
-@@ -777,7 +787,11 @@ static int sco_sock_recvmsg(struct socke
-
- release_sock(sk);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- return bt_sock_recvmsg(sock, msg, len, flags);
-+#else
-+ return bt_sock_recvmsg(iocb, sock, msg, len, flags);
-+#endif
- }
-
- static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Cocci] [PATCH 1/4] patches: remove bt_sock_stream_recvmsg() and bt_sock_recvmsg() from ifdefs
@ 2015-06-06 0:09 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:09 UTC (permalink / raw)
To: cocci
Both bt_sock_recvmsg() and bt_sock_stream_recvmsg() are used
within bluetooth code but the backport actually required is only
for the struct proto_ops and struct proto sendmsg and recvmsg
callbacks. The bt_sock_recvmsg() and bt_sock_stream_recvmsg()
are not callbacks, they are exported but are used all within
the code we provide and carry.
This will help simplify the network/0054-struct-proto_ops-sig
collateral evolution port to Coccinelle SmPL.
1 3.0.101 [ OK ]
2 3.1.10 [ OK ]
3 3.2.68 [ OK ]
4 3.3.8 [ OK ]
5 3.4.107 [ OK ]
6 3.5.7 [ OK ]
7 3.6.11 [ OK ]
8 3.7.10 [ OK ]
9 3.8.13 [ OK ]
10 3.9.11 [ OK ]
11 3.10.75 [ OK ]
12 3.11.10 [ OK ]
13 3.12.40 [ OK ]
14 3.13.11 [ OK ]
15 3.14.39 [ OK ]
16 3.15.10 [ OK ]
17 3.16.7 [ OK ]
18 3.17.8 [ OK ]
19 3.18.12 [ OK ]
20 3.19.5 [ OK ]
21 4.0.0 [ OK ]
22 4.1-rc1 [ OK ]
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
.../0054-struct-proto_ops-sig/bluetooth.patch | 92 ----------------------
1 file changed, 92 deletions(-)
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
index 614e551..1bd0ced 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
@@ -1,53 +1,3 @@
---- a/include/net/bluetooth/bluetooth.h
-+++ b/include/net/bluetooth/bluetooth.h
-@@ -245,10 +245,17 @@ int bt_sock_register(int proto, const s
- void bt_sock_unregister(int proto);
- void bt_sock_link(struct bt_sock_list *l, struct sock *s);
- void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags);
- int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags);
-+#else
-+int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags);
-+int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags);
-+#endif
- uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
- int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
- int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
---- a/net/bluetooth/af_bluetooth.c
-+++ b/net/bluetooth/af_bluetooth.c
-@@ -210,8 +210,13 @@ struct sock *bt_accept_dequeue(struct so
- }
- EXPORT_SYMBOL(bt_accept_dequeue);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags)
-+#else
-+int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
-@@ -283,8 +288,13 @@ static long bt_sock_data_wait(struct soc
- return timeo;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t size, int flags)
-+#else
-+int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t size, int flags)
-+#endif
- {
- struct sock *sk = sock->sk;
- int err = 0;
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -906,8 +906,13 @@ static void hci_sock_cmsg(struct sock *s
@@ -108,24 +58,6 @@
{
struct sock *sk = sock->sk;
struct l2cap_pinfo *pi = l2cap_pi(sk);
-@@ -1004,9 +1014,17 @@ static int l2cap_sock_recvmsg(struct soc
- release_sock(sk);
-
- if (sock->type == SOCK_STREAM)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- err = bt_sock_stream_recvmsg(sock, msg, len, flags);
-+#else
-+ err = bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
-+#endif
- else
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- err = bt_sock_recvmsg(sock, msg, len, flags);
-+#else
-+ err = bt_sock_recvmsg(iocb, sock, msg, len, flags);
-+#endif
-
- if (pi->chan->mode != L2CAP_MODE_ERTM)
- return err;
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -549,8 +549,13 @@ static int rfcomm_sock_getname(struct so
@@ -156,18 +88,6 @@
{
struct sock *sk = sock->sk;
struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
-@@ -627,7 +637,11 @@ static int rfcomm_sock_recvmsg(struct so
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- len = bt_sock_stream_recvmsg(sock, msg, size, flags);
-+#else
-+ len = bt_sock_stream_recvmsg(iocb, sock, msg, size, flags);
-+#endif
-
- lock_sock(sk);
- if (!(flags & MSG_PEEK) && len > 0)
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -688,8 +688,13 @@ static int sco_sock_getname(struct socke
@@ -198,15 +118,3 @@
{
struct sock *sk = sock->sk;
struct sco_pinfo *pi = sco_pi(sk);
-@@ -777,7 +787,11 @@ static int sco_sock_recvmsg(struct socke
-
- release_sock(sk);
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- return bt_sock_recvmsg(sock, msg, len, flags);
-+#else
-+ return bt_sock_recvmsg(iocb, sock, msg, len, flags);
-+#endif
- }
-
- static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 2/4] patches: change 0054-struct-proto_ops-sig backport strategy
2015-06-06 0:09 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-06 0:09 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:09 UTC (permalink / raw)
To: backports; +Cc: cocci, Luis R. Rodriguez
This modifies we backport the struct proto_ops and struct proto
declarations from adding #idefs around the function prototype
arguments to just declaring our own new backport callback for
older kernels with the extra argument which calls the the
upstream function. This is done because we cannot write an
SmPL grammar patch to backport the collateral evolution as we
do it now. The backport strategy we provide now is equivalent
in terms of functionality but also a lot more clear, it also
leaves the upstream code unmodified as much as possible, this
should enable anyone reviewing the code to be able to more
easily determine exactly what is going on.
1 3.0.101 [ OK ]
2 3.1.10 [ OK ]
3 3.2.68 [ OK ]
4 3.3.8 [ OK ]
5 3.4.107 [ OK ]
6 3.5.7 [ OK ]
7 3.6.11 [ OK ]
8 3.7.10 [ OK ]
9 3.8.13 [ OK ]
10 3.9.11 [ OK ]
11 3.10.75 [ OK ]
12 3.11.10 [ OK ]
13 3.12.40 [ OK ]
14 3.13.11 [ OK ]
15 3.14.39 [ OK ]
16 3.15.10 [ OK ]
17 3.16.7 [ OK ]
18 3.17.8 [ OK ]
19 3.18.12 [ OK ]
20 3.19.5 [ OK ]
21 4.0.0 [ OK ]
22 4.1-rc1 [ OK ]
real 53m48.791s
user 1437m15.048s
sys 217m20.652s
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
.../0054-struct-proto_ops-sig/bluetooth.patch | 235 +++++++++++++--------
.../0054-struct-proto_ops-sig/ieee802154.patch | 161 +++++++++-----
.../network/0054-struct-proto_ops-sig/nfc.patch | 138 ++++++++----
3 files changed, 356 insertions(+), 178 deletions(-)
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
index 1bd0ced..2cf5a9e 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
@@ -1,120 +1,187 @@
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
-@@ -906,8 +906,13 @@ static void hci_sock_cmsg(struct sock *s
- }
+@@ -953,6 +953,14 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
+
+ return err ? : copied;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags)
++{
++ return hci_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags)
-+#else
-+static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
-@@ -1065,8 +1070,13 @@ done:
- return err;
+ static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
+ struct msghdr *msg, size_t msglen)
+@@ -1189,6 +1196,13 @@ drop:
+ kfree_skb(skb);
+ goto done;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len)
++{
++ return hci_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
+ char __user *optval, unsigned int len)
+@@ -1345,8 +1358,13 @@ static const struct proto_ops hci_sock_ops = {
+ .release = hci_sock_release,
+ .bind = hci_sock_bind,
+ .getname = hci_sock_getname,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
+ .sendmsg = hci_sock_sendmsg,
+ .recvmsg = hci_sock_recvmsg,
+#else
-+static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct hci_mgmt_chan *chan;
++ .sendmsg = backport_hci_sock_sendmsg,
++ .recvmsg = backport_hci_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .ioctl = hci_sock_ioctl,
+ .poll = datagram_poll,
+ .listen = sock_no_listen,
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
-@@ -944,8 +944,13 @@ static int l2cap_sock_setsockopt(struct
+@@ -975,6 +975,13 @@ static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_l2cap_sock_sendmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return l2cap_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct l2cap_chan *chan = l2cap_pi(sk)->chan;
-@@ -976,8 +981,13 @@ static int l2cap_sock_sendmsg(struct soc
+ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
+ size_t len, int flags)
+@@ -1036,6 +1043,14 @@ done:
+ release_sock(sk);
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_l2cap_sock_recvmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return l2cap_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ /* Kill socket (only if zapped and orphan)
+ * Must be called on unlocked socket.
+@@ -1618,8 +1633,16 @@ static const struct proto_ops l2cap_sock_ops = {
+ .listen = l2cap_sock_listen,
+ .accept = l2cap_sock_accept,
+ .getname = l2cap_sock_getname,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
+ .sendmsg = l2cap_sock_sendmsg,
+#else
-+static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct l2cap_pinfo *pi = l2cap_pi(sk);
++ .sendmsg = backport_l2cap_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = l2cap_sock_recvmsg,
++#else
++ .recvmsg = backport_l2cap_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .poll = bt_sock_poll,
+ .ioctl = bt_sock_ioctl,
+ .mmap = sock_no_mmap,
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
-@@ -549,8 +549,13 @@ static int rfcomm_sock_getname(struct so
- return 0;
- }
+@@ -622,6 +622,13 @@ done:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int rfcomm_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
-@@ -615,8 +620,13 @@ done:
return sent;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rfcomm_sock_sendmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return rfcomm_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
size_t size, int flags)
-+#else
-+static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t size, int flags)
-+#endif
+@@ -647,6 +654,14 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
+
+ return len;
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rfcomm_sock_recvmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return rfcomm_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
{
- struct sock *sk = sock->sk;
- struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
+@@ -1044,8 +1059,16 @@ static const struct proto_ops rfcomm_sock_ops = {
+ .listen = rfcomm_sock_listen,
+ .accept = rfcomm_sock_accept,
+ .getname = rfcomm_sock_getname,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = rfcomm_sock_sendmsg,
++#else
++ .sendmsg = backport_rfcomm_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = rfcomm_sock_recvmsg,
++#else
++ .recvmsg = backport_rfcomm_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .shutdown = rfcomm_sock_shutdown,
+ .setsockopt = rfcomm_sock_setsockopt,
+ .getsockopt = rfcomm_sock_getsockopt,
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
-@@ -688,8 +688,13 @@ static int sco_sock_getname(struct socke
- return 0;
+@@ -713,6 +713,12 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+ release_sock(sk);
+ return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return sco_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
+ static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
{
- struct sock *sk = sock->sk;
- int err;
-@@ -758,8 +763,13 @@ static void sco_conn_defer_accept(struct
- }
+@@ -779,6 +785,13 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
+
+ return bt_sock_recvmsg(sock, msg, len, flags);
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return sco_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
+ {
+@@ -1178,8 +1191,16 @@ static const struct proto_ops sco_sock_ops = {
+ .listen = sco_sock_listen,
+ .accept = sco_sock_accept,
+ .getname = sco_sock_getname,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
+ .sendmsg = sco_sock_sendmsg,
+#else
-+static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct sco_pinfo *pi = sco_pi(sk);
++ .sendmsg = backport_sco_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = sco_sock_recvmsg,
++#else
++ .recvmsg = backport_sco_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .poll = bt_sock_poll,
+ .ioctl = bt_sock_ioctl,
+ .mmap = sock_no_mmap,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
index cfb77f3..0497dbe 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
@@ -1,79 +1,134 @@
--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
-@@ -96,12 +96,21 @@ static int ieee802154_sock_release(struc
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int ieee802154_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
+@@ -101,8 +101,19 @@ static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
{
struct sock *sk = sock->sk;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
return sk->sk_prot->sendmsg(sk, msg, len);
+#else
-+ return sk->sk_prot->sendmsg(iocb, sk, msg, len);
-+#endif
++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_ieee802154_sock_sendmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return ieee802154_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
-@@ -253,7 +262,12 @@ static int raw_disconnect(struct sock *s
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
-+#else
-+static int raw_sendmsg(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t size)
-+#endif
- {
- struct net_device *dev;
- unsigned int mtu;
-@@ -324,8 +338,13 @@ out:
+ int addr_len)
+@@ -323,6 +334,12 @@ out_dev:
+ out:
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_raw_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return raw_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len)
-+#else
-+static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-+ size_t len, int noblock, int flags, int *addr_len)
-+#endif
- {
- size_t copied = 0;
- int err = -EOPNOTSUPP;
-@@ -612,7 +631,12 @@ static int dgram_disconnect(struct sock
- return 0;
+@@ -356,6 +373,13 @@ out:
+ return err;
+ return copied;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_raw_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int noblock,
++ int flags, int *addr_len){
++ return raw_recvmsg(sock, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
+ {
+@@ -409,8 +433,16 @@ static struct proto ieee802154_raw_prot = {
+ .obj_size = sizeof(struct sock),
+ .close = raw_close,
+ .bind = raw_bind,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int dgram_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
+ .sendmsg = raw_sendmsg,
+#else
-+static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t size)
-+#endif
- {
- struct net_device *dev;
- unsigned int mtu;
-@@ -711,8 +735,14 @@ out:
++ .sendmsg = backport_raw_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = raw_recvmsg,
++#else
++ .recvmsg = backport_raw_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .hash = raw_hash,
+ .unhash = raw_unhash,
+ .connect = raw_connect,
+@@ -434,7 +466,11 @@ static const struct proto_ops ieee802154_raw_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = sock_common_setsockopt,
+ .getsockopt = sock_common_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = ieee802154_sock_sendmsg,
++#else
++ .sendmsg = backport_ieee802154_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .recvmsg = sock_common_recvmsg,
+ .mmap = sock_no_mmap,
+ .sendpage = sock_no_sendpage,
+@@ -710,6 +746,12 @@ out_dev:
+ out:
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_dgram_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return dgram_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len)
-+#else
-+static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t len, int noblock,
-+ int flags, int *addr_len)
-+#endif
+@@ -751,6 +793,13 @@ out:
+ return err;
+ return copied;
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int noblock,
++ int flags, int *addr_len){
++ return dgram_recvmsg(sock, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+ static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
{
- size_t copied = 0;
- int err = -EOPNOTSUPP;
+@@ -947,8 +996,16 @@ static struct proto ieee802154_dgram_prot = {
+ .init = dgram_init,
+ .close = dgram_close,
+ .bind = dgram_bind,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = dgram_sendmsg,
++#else
++ .sendmsg = backport_dgram_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = dgram_recvmsg,
++#else
++ .recvmsg = backport_dgram_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .hash = dgram_hash,
+ .unhash = dgram_unhash,
+ .connect = dgram_connect,
+@@ -973,7 +1030,11 @@ static const struct proto_ops ieee802154_dgram_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = sock_common_setsockopt,
+ .getsockopt = sock_common_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = ieee802154_sock_sendmsg,
++#else
++ .sendmsg = backport_ieee802154_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .recvmsg = sock_common_recvmsg,
+ .mmap = sock_no_mmap,
+ .sendpage = sock_no_sendpage,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
index 3bc5fc0..e29c4d8 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
@@ -1,59 +1,115 @@
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
-@@ -750,8 +750,13 @@ error:
- return ret;
- }
+@@ -792,6 +792,12 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
-@@ -793,8 +798,13 @@ static int llcp_sock_sendmsg(struct sock
return nfc_llcp_send_i_frame(llcp_sock, msg, len);
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return llcp_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
size_t len, int flags)
-+#else
-+static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
---- a/net/nfc/rawsock.c
-+++ b/net/nfc/rawsock.c
-@@ -211,7 +211,12 @@ static void rawsock_tx_work(struct work_
- }
+@@ -882,6 +888,13 @@ done:
+
+ return copied;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return llcp_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static const struct proto_ops llcp_sock_ops = {
+ .family = PF_NFC,
+@@ -898,8 +911,16 @@ static const struct proto_ops llcp_sock_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = nfc_llcp_setsockopt,
+ .getsockopt = nfc_llcp_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = llcp_sock_sendmsg,
++#else
++ .sendmsg = backport_llcp_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+ .recvmsg = llcp_sock_recvmsg,
+#else
-+static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct nfc_dev *dev = nfc_rawsock(sk)->dev;
-@@ -247,8 +252,13 @@ static int rawsock_sendmsg(struct socket
++ .recvmsg = backport_llcp_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
+@@ -919,7 +940,11 @@ static const struct proto_ops llcp_rawsock_ops = {
+ .setsockopt = sock_no_setsockopt,
+ .getsockopt = sock_no_getsockopt,
+ .sendmsg = sock_no_sendmsg,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = llcp_sock_recvmsg,
++#else
++ .recvmsg = backport_llcp_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
+--- a/net/nfc/rawsock.c
++++ b/net/nfc/rawsock.c
+@@ -246,6 +246,12 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+
return len;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return rawsock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
int flags)
+@@ -274,6 +280,12 @@ static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
+
+ return rc ? : copied;
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int flags){
++ return rawsock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+ static const struct proto_ops rawsock_ops = {
+ .family = PF_NFC,
+@@ -290,8 +302,16 @@ static const struct proto_ops rawsock_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = sock_no_setsockopt,
+ .getsockopt = sock_no_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = rawsock_sendmsg,
++#else
++ .sendmsg = backport_rawsock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = rawsock_recvmsg,
+#else
-+static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
++ .recvmsg = backport_rawsock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
+@@ -311,7 +331,11 @@ static const struct proto_ops rawsock_raw_ops = {
+ .setsockopt = sock_no_setsockopt,
+ .getsockopt = sock_no_getsockopt,
+ .sendmsg = sock_no_sendmsg,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = rawsock_recvmsg,
++#else
++ .recvmsg = backport_rawsock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Cocci] [PATCH 2/4] patches: change 0054-struct-proto_ops-sig backport strategy
@ 2015-06-06 0:09 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:09 UTC (permalink / raw)
To: cocci
This modifies we backport the struct proto_ops and struct proto
declarations from adding #idefs around the function prototype
arguments to just declaring our own new backport callback for
older kernels with the extra argument which calls the the
upstream function. This is done because we cannot write an
SmPL grammar patch to backport the collateral evolution as we
do it now. The backport strategy we provide now is equivalent
in terms of functionality but also a lot more clear, it also
leaves the upstream code unmodified as much as possible, this
should enable anyone reviewing the code to be able to more
easily determine exactly what is going on.
1 3.0.101 [ OK ]
2 3.1.10 [ OK ]
3 3.2.68 [ OK ]
4 3.3.8 [ OK ]
5 3.4.107 [ OK ]
6 3.5.7 [ OK ]
7 3.6.11 [ OK ]
8 3.7.10 [ OK ]
9 3.8.13 [ OK ]
10 3.9.11 [ OK ]
11 3.10.75 [ OK ]
12 3.11.10 [ OK ]
13 3.12.40 [ OK ]
14 3.13.11 [ OK ]
15 3.14.39 [ OK ]
16 3.15.10 [ OK ]
17 3.16.7 [ OK ]
18 3.17.8 [ OK ]
19 3.18.12 [ OK ]
20 3.19.5 [ OK ]
21 4.0.0 [ OK ]
22 4.1-rc1 [ OK ]
real 53m48.791s
user 1437m15.048s
sys 217m20.652s
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
.../0054-struct-proto_ops-sig/bluetooth.patch | 235 +++++++++++++--------
.../0054-struct-proto_ops-sig/ieee802154.patch | 161 +++++++++-----
.../network/0054-struct-proto_ops-sig/nfc.patch | 138 ++++++++----
3 files changed, 356 insertions(+), 178 deletions(-)
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
index 1bd0ced..2cf5a9e 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
@@ -1,120 +1,187 @@
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
-@@ -906,8 +906,13 @@ static void hci_sock_cmsg(struct sock *s
- }
+@@ -953,6 +953,14 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
+
+ return err ? : copied;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags)
++{
++ return hci_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags)
-+#else
-+static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
-@@ -1065,8 +1070,13 @@ done:
- return err;
+ static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
+ struct msghdr *msg, size_t msglen)
+@@ -1189,6 +1196,13 @@ drop:
+ kfree_skb(skb);
+ goto done;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len)
++{
++ return hci_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
+ char __user *optval, unsigned int len)
+@@ -1345,8 +1358,13 @@ static const struct proto_ops hci_sock_ops = {
+ .release = hci_sock_release,
+ .bind = hci_sock_bind,
+ .getname = hci_sock_getname,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
+ .sendmsg = hci_sock_sendmsg,
+ .recvmsg = hci_sock_recvmsg,
+#else
-+static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct hci_mgmt_chan *chan;
++ .sendmsg = backport_hci_sock_sendmsg,
++ .recvmsg = backport_hci_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .ioctl = hci_sock_ioctl,
+ .poll = datagram_poll,
+ .listen = sock_no_listen,
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
-@@ -944,8 +944,13 @@ static int l2cap_sock_setsockopt(struct
+@@ -975,6 +975,13 @@ static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_l2cap_sock_sendmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return l2cap_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct l2cap_chan *chan = l2cap_pi(sk)->chan;
-@@ -976,8 +981,13 @@ static int l2cap_sock_sendmsg(struct soc
+ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
+ size_t len, int flags)
+@@ -1036,6 +1043,14 @@ done:
+ release_sock(sk);
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_l2cap_sock_recvmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return l2cap_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ /* Kill socket (only if zapped and orphan)
+ * Must be called on unlocked socket.
+@@ -1618,8 +1633,16 @@ static const struct proto_ops l2cap_sock_ops = {
+ .listen = l2cap_sock_listen,
+ .accept = l2cap_sock_accept,
+ .getname = l2cap_sock_getname,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
+ .sendmsg = l2cap_sock_sendmsg,
+#else
-+static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct l2cap_pinfo *pi = l2cap_pi(sk);
++ .sendmsg = backport_l2cap_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = l2cap_sock_recvmsg,
++#else
++ .recvmsg = backport_l2cap_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .poll = bt_sock_poll,
+ .ioctl = bt_sock_ioctl,
+ .mmap = sock_no_mmap,
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
-@@ -549,8 +549,13 @@ static int rfcomm_sock_getname(struct so
- return 0;
- }
+@@ -622,6 +622,13 @@ done:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int rfcomm_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
-@@ -615,8 +620,13 @@ done:
return sent;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rfcomm_sock_sendmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return rfcomm_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
size_t size, int flags)
-+#else
-+static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t size, int flags)
-+#endif
+@@ -647,6 +654,14 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
+
+ return len;
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rfcomm_sock_recvmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return rfcomm_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
{
- struct sock *sk = sock->sk;
- struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
+@@ -1044,8 +1059,16 @@ static const struct proto_ops rfcomm_sock_ops = {
+ .listen = rfcomm_sock_listen,
+ .accept = rfcomm_sock_accept,
+ .getname = rfcomm_sock_getname,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = rfcomm_sock_sendmsg,
++#else
++ .sendmsg = backport_rfcomm_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = rfcomm_sock_recvmsg,
++#else
++ .recvmsg = backport_rfcomm_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .shutdown = rfcomm_sock_shutdown,
+ .setsockopt = rfcomm_sock_setsockopt,
+ .getsockopt = rfcomm_sock_getsockopt,
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
-@@ -688,8 +688,13 @@ static int sco_sock_getname(struct socke
- return 0;
+@@ -713,6 +713,12 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+ release_sock(sk);
+ return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return sco_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
+ static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
{
- struct sock *sk = sock->sk;
- int err;
-@@ -758,8 +763,13 @@ static void sco_conn_defer_accept(struct
- }
+@@ -779,6 +785,13 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
+
+ return bt_sock_recvmsg(sock, msg, len, flags);
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return sco_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
+ {
+@@ -1178,8 +1191,16 @@ static const struct proto_ops sco_sock_ops = {
+ .listen = sco_sock_listen,
+ .accept = sco_sock_accept,
+ .getname = sco_sock_getname,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
+ .sendmsg = sco_sock_sendmsg,
+#else
-+static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct sco_pinfo *pi = sco_pi(sk);
++ .sendmsg = backport_sco_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = sco_sock_recvmsg,
++#else
++ .recvmsg = backport_sco_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .poll = bt_sock_poll,
+ .ioctl = bt_sock_ioctl,
+ .mmap = sock_no_mmap,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
index cfb77f3..0497dbe 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
@@ -1,79 +1,134 @@
--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
-@@ -96,12 +96,21 @@ static int ieee802154_sock_release(struc
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int ieee802154_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
+@@ -101,8 +101,19 @@ static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
{
struct sock *sk = sock->sk;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
return sk->sk_prot->sendmsg(sk, msg, len);
+#else
-+ return sk->sk_prot->sendmsg(iocb, sk, msg, len);
-+#endif
++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_ieee802154_sock_sendmsg(struct kiocb *iocb,
++ struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return ieee802154_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
-@@ -253,7 +262,12 @@ static int raw_disconnect(struct sock *s
- return 0;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
-+#else
-+static int raw_sendmsg(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t size)
-+#endif
- {
- struct net_device *dev;
- unsigned int mtu;
-@@ -324,8 +338,13 @@ out:
+ int addr_len)
+@@ -323,6 +334,12 @@ out_dev:
+ out:
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_raw_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return raw_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len)
-+#else
-+static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-+ size_t len, int noblock, int flags, int *addr_len)
-+#endif
- {
- size_t copied = 0;
- int err = -EOPNOTSUPP;
-@@ -612,7 +631,12 @@ static int dgram_disconnect(struct sock
- return 0;
+@@ -356,6 +373,13 @@ out:
+ return err;
+ return copied;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_raw_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int noblock,
++ int flags, int *addr_len){
++ return raw_recvmsg(sock, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
+ {
+@@ -409,8 +433,16 @@ static struct proto ieee802154_raw_prot = {
+ .obj_size = sizeof(struct sock),
+ .close = raw_close,
+ .bind = raw_bind,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int dgram_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
+ .sendmsg = raw_sendmsg,
+#else
-+static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t size)
-+#endif
- {
- struct net_device *dev;
- unsigned int mtu;
-@@ -711,8 +735,14 @@ out:
++ .sendmsg = backport_raw_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = raw_recvmsg,
++#else
++ .recvmsg = backport_raw_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .hash = raw_hash,
+ .unhash = raw_unhash,
+ .connect = raw_connect,
+@@ -434,7 +466,11 @@ static const struct proto_ops ieee802154_raw_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = sock_common_setsockopt,
+ .getsockopt = sock_common_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = ieee802154_sock_sendmsg,
++#else
++ .sendmsg = backport_ieee802154_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .recvmsg = sock_common_recvmsg,
+ .mmap = sock_no_mmap,
+ .sendpage = sock_no_sendpage,
+@@ -710,6 +746,12 @@ out_dev:
+ out:
return err;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_dgram_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return dgram_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len)
-+#else
-+static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk,
-+ struct msghdr *msg, size_t len, int noblock,
-+ int flags, int *addr_len)
-+#endif
+@@ -751,6 +793,13 @@ out:
+ return err;
+ return copied;
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int noblock,
++ int flags, int *addr_len){
++ return dgram_recvmsg(sock, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+ static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
{
- size_t copied = 0;
- int err = -EOPNOTSUPP;
+@@ -947,8 +996,16 @@ static struct proto ieee802154_dgram_prot = {
+ .init = dgram_init,
+ .close = dgram_close,
+ .bind = dgram_bind,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = dgram_sendmsg,
++#else
++ .sendmsg = backport_dgram_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = dgram_recvmsg,
++#else
++ .recvmsg = backport_dgram_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .hash = dgram_hash,
+ .unhash = dgram_unhash,
+ .connect = dgram_connect,
+@@ -973,7 +1030,11 @@ static const struct proto_ops ieee802154_dgram_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = sock_common_setsockopt,
+ .getsockopt = sock_common_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = ieee802154_sock_sendmsg,
++#else
++ .sendmsg = backport_ieee802154_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .recvmsg = sock_common_recvmsg,
+ .mmap = sock_no_mmap,
+ .sendpage = sock_no_sendpage,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
index 3bc5fc0..e29c4d8 100644
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
@@ -1,59 +1,115 @@
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
-@@ -750,8 +750,13 @@ error:
- return ret;
- }
+@@ -792,6 +792,12 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
-+#else
-+static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk);
-@@ -793,8 +798,13 @@ static int llcp_sock_sendmsg(struct sock
return nfc_llcp_send_i_frame(llcp_sock, msg, len);
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return llcp_sock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
size_t len, int flags)
-+#else
-+static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
---- a/net/nfc/rawsock.c
-+++ b/net/nfc/rawsock.c
-@@ -211,7 +211,12 @@ static void rawsock_tx_work(struct work_
- }
+@@ -882,6 +888,13 @@ done:
+
+ return copied;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int flags){
++ return llcp_sock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+ static const struct proto_ops llcp_sock_ops = {
+ .family = PF_NFC,
+@@ -898,8 +911,16 @@ static const struct proto_ops llcp_sock_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = nfc_llcp_setsockopt,
+ .getsockopt = nfc_llcp_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = llcp_sock_sendmsg,
++#else
++ .sendmsg = backport_llcp_sock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+ .recvmsg = llcp_sock_recvmsg,
+#else
-+static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+#endif
- {
- struct sock *sk = sock->sk;
- struct nfc_dev *dev = nfc_rawsock(sk)->dev;
-@@ -247,8 +252,13 @@ static int rawsock_sendmsg(struct socket
++ .recvmsg = backport_llcp_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
+@@ -919,7 +940,11 @@ static const struct proto_ops llcp_rawsock_ops = {
+ .setsockopt = sock_no_setsockopt,
+ .getsockopt = sock_no_getsockopt,
+ .sendmsg = sock_no_sendmsg,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = llcp_sock_recvmsg,
++#else
++ .recvmsg = backport_llcp_sock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
+--- a/net/nfc/rawsock.c
++++ b/net/nfc/rawsock.c
+@@ -246,6 +246,12 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+
return len;
}
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len){
++ return rawsock_sendmsg(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
int flags)
+@@ -274,6 +280,12 @@ static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
+
+ return rc ? : copied;
+ }
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int flags){
++ return rawsock_recvmsg(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+ static const struct proto_ops rawsock_ops = {
+ .family = PF_NFC,
+@@ -290,8 +302,16 @@ static const struct proto_ops rawsock_ops = {
+ .shutdown = sock_no_shutdown,
+ .setsockopt = sock_no_setsockopt,
+ .getsockopt = sock_no_getsockopt,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = rawsock_sendmsg,
++#else
++ .sendmsg = backport_rawsock_sendmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = rawsock_recvmsg,
+#else
-+static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags)
-+#endif
- {
- int noblock = flags & MSG_DONTWAIT;
- struct sock *sk = sock->sk;
++ .recvmsg = backport_rawsock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
+@@ -311,7 +331,11 @@ static const struct proto_ops rawsock_raw_ops = {
+ .setsockopt = sock_no_setsockopt,
+ .getsockopt = sock_no_getsockopt,
+ .sendmsg = sock_no_sendmsg,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = rawsock_recvmsg,
++#else
++ .recvmsg = backport_rawsock_recvmsg,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+ .mmap = sock_no_mmap,
+ };
+
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
2015-06-06 0:09 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-06 0:10 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:10 UTC (permalink / raw)
To: backports; +Cc: cocci, Luis R. Rodriguez
If you have an SmPL patch that you think is ready to replace
a series of unified diff patches you can pass as an argument
to gentree.py '--prove-cocci' with the cocci file as the
an extra argument and gentree.py will try to prove equivalence
between the unified diff series and your Coccinelle SmPL patch.
You can use this as a guide when trying to replace an existing
unified diff series carried within backports with a respective
Coccinelle SmPL patch. You can use this to get a warm fuzzy or
to provide backports maintainers with a warm fuzzy of comfort
that your SmPL patch is sufficient.
In practice you might end up discovering as differences:
a) minor space cosmetic differences between what the Coccinelle
engine does and what we as humans typically would do
Coccinelle has already received substantial modificaitons to
address some of these minor spacing changes, but some might
still exist.
b) new code which previously was not modified, these are
transformations which Coccinelle is providied to use,
and hence further automating our backporting effort.
If provide a backport of a collateral evolution in
SmPL form it means we only have to write it once.
c) bugs within Coccinelle
a) and b) the most common differences observed, whereas we
have yet to find c). If you find a) or c) please report the
differences on the Coccinelle development mailing list.
The algorithm used for SmPL patch equivalence proof is as follows,
using the command below:
mcgrof@cerro ~/backports (git::master)$ ./gentree.py --clean --prove-cocci \
patches/collateral-evolutions/network/09-threaded-irq.cocci \
/home/mcgrof/linux-next/ \
/home/mcgrof/build/backports-20131206
When this is run gentree.py will first copy code we wish to backport
from linux-next into two separate directories:
1) /home/mcgrof/build/backports-20131206
We then only apply the Coccinelle SmPL patch 09-threaded-irq.cocci
2) /home/mcgrof/build/backports-20131206.orig
We then only apply the unified diff patches found within the directory:
patches/collateral-evolutions/network/09-threaded-irq/
At this point we now have two treees with two different backporting
strategies. Internally when --prove-cocci is used gentree.py creates
within backports-20131206 a git to keep track of differences, this
includes application of the 09-threaded-irq.cocci patch. We take
advantage of the fact git is used then and replace all the files
within backports-20131206.orig into backports-20131206 and just
ask git for the differences.
In this particular case the diff stat shown reveals huge amount of
differences, in this case upon inspecting the changes it reveals
that using Coccinelle has enabled the generalized backport to
propagate into a lot of other device drivers, and hence doing
more automatic backport work for us. This is precicely why we
want to generalize backports in Coccinelle SmPL form when possible.
A diff stat with no output would mean that there is a perfect
equivalence.
The output of the command:
Copy original source files ...
Apply patches ...
Proving Coccinelle SmPL patch: 09-threaded-irq.cocci
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_b43_b43.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_iwlwifi_pcie_internal.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_ti_wlcore_main.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_b43_main.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_ti_wlcore_main_extra.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_iwlwifi_pcie_trans.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_ti_wlcore_wlcore.patch
Review the difference between what the tree looks like
by applying your SmPL patch, then reverting that and
only applying your the patches in the patch series.
Change directory to /home/mcgrof/build/backports-20131206 and run 'git diff'
diff stat of the changes:
drivers/media/platform/via-camera.c | 28 +-----------
drivers/media/radio/radio-wl1273.c | 28 +-----------
drivers/media/radio/si470x/radio-si470x-i2c.c | 24 +----------
drivers/media/radio/si470x/radio-si470x.h | 3 --
drivers/net/ieee802154/mrf24j40.c | 20 ---------
drivers/net/wireless/ath/wil6210/interrupt.c | 62 +++------------------------
drivers/net/wireless/ath/wil6210/wil6210.h | 3 --
drivers/net/wireless/b43/main.c | 21 ++++-----
drivers/net/wireless/cw1200/cw1200_sdio.c | 21 ---------
drivers/net/wireless/cw1200/cw1200_spi.c | 27 +-----------
drivers/net/wireless/iwlwifi/pcie/internal.h | 3 ++
drivers/net/wireless/iwlwifi/pcie/trans.c | 34 ++++++---------
drivers/net/wireless/ti/wlcore/main.c | 26 +++++------
drivers/nfc/microread/i2c.c | 27 +-----------
drivers/nfc/pn544/i2c.c | 27 +-----------
drivers/regulator/da9063-regulator.c | 26 -----------
drivers/regulator/lp8755.c | 23 +---------
17 files changed, 52 insertions(+), 351 deletions(-)
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
gentree.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 63 insertions(+), 8 deletions(-)
diff --git a/gentree.py b/gentree.py
index 636ea60..9e9293b 100755
--- a/gentree.py
+++ b/gentree.py
@@ -485,14 +485,30 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
a specific SmPL patch.
"""
logwrite('Applying patches from %s to %s ...' % (patch_src, target_dir))
- test_cocci = args.test_cocci or args.profile_cocci
+ test_cocci = args.test_cocci or args.profile_cocci or args.prove_cocci
+ # We don't skip all patches for SmPL proof, we need to use its old series
+ skip_patches = args.profile_cocci or args.test_cocci
test_cocci_found = False
+ prove_cocci_tmp_dir = ''
+ if args.prove_cocci:
+ test_cocci = test_cocci.split('/')[-1]
+ prove_cocci_tmp_dir = target_dir + '.orig'
+ shutil.rmtree(prove_cocci_tmp_dir, ignore_errors=True)
+ copytree(target_dir, prove_cocci_tmp_dir)
patches = []
sempatches = []
for root, dirs, files in os.walk(os.path.join(source_dir, patch_src)):
for f in files:
- if not test_cocci and f.endswith('.patch'):
- patches.append(os.path.join(root, f))
+ if not skip_patches and f.endswith('.patch'):
+ if args.prove_cocci:
+ # As an example if you use --prove-cocci patches/collateral-evolutions/network/09-threaded-irq.cocci
+ # the patches under 09-threaded-irq will be used for the proof.
+ proof_to_test_dir = test_cocci.split('/')[-1].split('.cocci')[0]
+ if proof_to_test_dir in os.path.join(root, f):
+ logwrite("Aggregating patch for Coccinelle SmPL %s proof: %s" % (proof_to_test_dir, f))
+ patches.append(os.path.join(root, f))
+ else:
+ patches.append(os.path.join(root, f))
if f.endswith('.cocci'):
if test_cocci:
if f not in test_cocci:
@@ -502,6 +518,8 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
logwrite("Testing Coccinelle SmPL patch: %s" % test_cocci)
elif args.profile_cocci:
logwrite("Profiling Coccinelle SmPL patch: %s" % test_cocci)
+ elif args.prove_cocci:
+ logwrite("Proving Coccinelle SmPL patch: %s" % test_cocci)
sempatches.append(os.path.join(root, f))
patches.sort()
prefix_len = len(os.path.join(source_dir, patch_src)) + 1
@@ -533,10 +551,13 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
fullfn = os.path.join(target_dir, patched_file)
shutil.copyfile(fullfn, fullfn + '.orig_file')
+ patch_target_dir = target_dir
+ if args.prove_cocci:
+ patch_target_dir = prove_cocci_tmp_dir
process = subprocess.Popen(['patch', '-p1'], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
close_fds=True, universal_newlines=True,
- cwd=target_dir)
+ cwd=patch_target_dir)
output = process.communicate(input=open(pfile, 'r').read())[0]
output = output.split('\n')
if output[-1] == '':
@@ -578,7 +599,13 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
for f in files:
if f[-5:] == '.orig' or f[-4:] == '.rej':
os.unlink(os.path.join(root, f))
- git_debug_snapshot(args, "apply %s patch %s" % (desc, print_name))
+ if patch_target_dir != target_dir:
+ for root, dirs, files in os.walk(patch_target_dir):
+ for f in files:
+ if f[-5:] == '.orig' or f[-4:] == '.rej':
+ os.unlink(os.path.join(root, f))
+ if not args.prove_cocci:
+ git_debug_snapshot(args, "apply %s patch %s" % (desc, print_name))
sempatches.sort()
prefix_len = len(os.path.join(source_dir, patch_src)) + 1
@@ -615,8 +642,27 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
for f in files:
if f.endswith('.cocci_backup'):
os.unlink(os.path.join(root, f))
+ if patch_target_dir != target_dir:
+ for root, dirs, files in os.walk(patch_target_dir):
+ for f in files:
+ if f.endswith('.cocci_backup'):
+ os.unlink(os.path.join(root, f))
git_debug_snapshot(args, "apply %s SmPL patch %s" % (desc, print_name))
+ if args.prove_cocci:
+ copytree(prove_cocci_tmp_dir, target_dir, ignore=shutil.ignore_patterns('.git'))
+ shutil.rmtree(prove_cocci_tmp_dir, ignore_errors=True)
+ diff_stat = git.diff(tree=target_dir, extra_args=['--stat'])
+ if len(diff_stat) == 0:
+ logwrite('\nSmPL patch fully replaces patch series')
+ else:
+ logwrite('\nReview the difference between what the tree looks like ')
+ logwrite('by applying your SmPL patch, then reverting that and ')
+ logwrite('only applying your the patches in the patch series.')
+ logwrite('')
+ logwrite('Change directory to %s and run \'git diff\'' % target_dir)
+ logwrite('diff stat of the changes:\n')
+ logwrite(diff_stat)
if test_cocci and test_cocci_found:
logwrite('Done!')
sys.exit(0)
@@ -675,6 +721,11 @@ def _main():
help='Only use the cocci file passed and pass --profile to Coccinelle, ' +
'also creates a git repo on the target directory for easy inspection ' +
'of changes done by Coccinelle.')
+ parser.add_argument('--prove-cocci', metavar='<sp_file>', type=str, default=None,
+ help='Only use the cocci file passed for Coccinelle and prove that it provides ' +
+ 'sufficient replacement for the patches under similar path name. Running ' +
+ 'git diff on the target directory suffices to show you what extra things' +
+ 'your SmPL patch did or what it didn\'t cover.')
args = parser.parse_args()
# When building a package we use CPTCFG as we can rely on the
@@ -721,6 +772,7 @@ def _main():
kup_test=args.kup_test,
test_cocci=args.test_cocci,
profile_cocci=args.profile_cocci,
+ prove_cocci=args.prove_cocci,
logwrite=logwrite)
def process(kerneldir, copy_list_file, git_revision=None,
@@ -730,6 +782,7 @@ def process(kerneldir, copy_list_file, git_revision=None,
kup_test=False,
test_cocci=None,
profile_cocci=None,
+ prove_cocci=None,
logwrite=lambda x:None,
git_tracked_version=False):
class Args(object):
@@ -738,7 +791,8 @@ def process(kerneldir, copy_list_file, git_revision=None,
gitdebug, verbose, extra_driver, kup,
kup_test,
test_cocci,
- profile_cocci):
+ profile_cocci,
+ prove_cocci):
self.kerneldir = kerneldir
self.copy_list = copy_list_file
self.git_revision = git_revision
@@ -753,7 +807,8 @@ def process(kerneldir, copy_list_file, git_revision=None,
self.kup_test = kup_test
self.test_cocci = test_cocci
self.profile_cocci = profile_cocci
- if self.test_cocci or self.profile_cocci:
+ self.prove_cocci = prove_cocci
+ if self.test_cocci or self.profile_cocci or self.prove_cocci:
self.gitdebug = True
def git_paranoia(tree=None, logwrite=lambda x:None):
data = git.paranoia(tree)
@@ -767,7 +822,7 @@ def process(kerneldir, copy_list_file, git_revision=None,
args = Args(kerneldir, copy_list_file,
git_revision, bpid, clean, refresh, base_name,
gitdebug, verbose, extra_driver, kup, kup_test,
- test_cocci, profile_cocci)
+ test_cocci, profile_cocci, prove_cocci)
rel_prep = None
if bpid.integrate:
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Cocci] [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
@ 2015-06-06 0:10 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:10 UTC (permalink / raw)
To: cocci
If you have an SmPL patch that you think is ready to replace
a series of unified diff patches you can pass as an argument
to gentree.py '--prove-cocci' with the cocci file as the
an extra argument and gentree.py will try to prove equivalence
between the unified diff series and your Coccinelle SmPL patch.
You can use this as a guide when trying to replace an existing
unified diff series carried within backports with a respective
Coccinelle SmPL patch. You can use this to get a warm fuzzy or
to provide backports maintainers with a warm fuzzy of comfort
that your SmPL patch is sufficient.
In practice you might end up discovering as differences:
a) minor space cosmetic differences between what the Coccinelle
engine does and what we as humans typically would do
Coccinelle has already received substantial modificaitons to
address some of these minor spacing changes, but some might
still exist.
b) new code which previously was not modified, these are
transformations which Coccinelle is providied to use,
and hence further automating our backporting effort.
If provide a backport of a collateral evolution in
SmPL form it means we only have to write it once.
c) bugs within Coccinelle
a) and b) the most common differences observed, whereas we
have yet to find c). If you find a) or c) please report the
differences on the Coccinelle development mailing list.
The algorithm used for SmPL patch equivalence proof is as follows,
using the command below:
mcgrof at cerro ~/backports (git::master)$ ./gentree.py --clean --prove-cocci \
patches/collateral-evolutions/network/09-threaded-irq.cocci \
/home/mcgrof/linux-next/ \
/home/mcgrof/build/backports-20131206
When this is run gentree.py will first copy code we wish to backport
from linux-next into two separate directories:
1) /home/mcgrof/build/backports-20131206
We then only apply the Coccinelle SmPL patch 09-threaded-irq.cocci
2) /home/mcgrof/build/backports-20131206.orig
We then only apply the unified diff patches found within the directory:
patches/collateral-evolutions/network/09-threaded-irq/
At this point we now have two treees with two different backporting
strategies. Internally when --prove-cocci is used gentree.py creates
within backports-20131206 a git to keep track of differences, this
includes application of the 09-threaded-irq.cocci patch. We take
advantage of the fact git is used then and replace all the files
within backports-20131206.orig into backports-20131206 and just
ask git for the differences.
In this particular case the diff stat shown reveals huge amount of
differences, in this case upon inspecting the changes it reveals
that using Coccinelle has enabled the generalized backport to
propagate into a lot of other device drivers, and hence doing
more automatic backport work for us. This is precicely why we
want to generalize backports in Coccinelle SmPL form when possible.
A diff stat with no output would mean that there is a perfect
equivalence.
The output of the command:
Copy original source files ...
Apply patches ...
Proving Coccinelle SmPL patch: 09-threaded-irq.cocci
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_b43_b43.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_iwlwifi_pcie_internal.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_ti_wlcore_main.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_b43_main.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_ti_wlcore_main_extra.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_iwlwifi_pcie_trans.patch
Aggregating patch for Coccinelle SmPL 09-threaded-irq proof: drivers_net_wireless_ti_wlcore_wlcore.patch
Review the difference between what the tree looks like
by applying your SmPL patch, then reverting that and
only applying your the patches in the patch series.
Change directory to /home/mcgrof/build/backports-20131206 and run 'git diff'
diff stat of the changes:
drivers/media/platform/via-camera.c | 28 +-----------
drivers/media/radio/radio-wl1273.c | 28 +-----------
drivers/media/radio/si470x/radio-si470x-i2c.c | 24 +----------
drivers/media/radio/si470x/radio-si470x.h | 3 --
drivers/net/ieee802154/mrf24j40.c | 20 ---------
drivers/net/wireless/ath/wil6210/interrupt.c | 62 +++------------------------
drivers/net/wireless/ath/wil6210/wil6210.h | 3 --
drivers/net/wireless/b43/main.c | 21 ++++-----
drivers/net/wireless/cw1200/cw1200_sdio.c | 21 ---------
drivers/net/wireless/cw1200/cw1200_spi.c | 27 +-----------
drivers/net/wireless/iwlwifi/pcie/internal.h | 3 ++
drivers/net/wireless/iwlwifi/pcie/trans.c | 34 ++++++---------
drivers/net/wireless/ti/wlcore/main.c | 26 +++++------
drivers/nfc/microread/i2c.c | 27 +-----------
drivers/nfc/pn544/i2c.c | 27 +-----------
drivers/regulator/da9063-regulator.c | 26 -----------
drivers/regulator/lp8755.c | 23 +---------
17 files changed, 52 insertions(+), 351 deletions(-)
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
gentree.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 63 insertions(+), 8 deletions(-)
diff --git a/gentree.py b/gentree.py
index 636ea60..9e9293b 100755
--- a/gentree.py
+++ b/gentree.py
@@ -485,14 +485,30 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
a specific SmPL patch.
"""
logwrite('Applying patches from %s to %s ...' % (patch_src, target_dir))
- test_cocci = args.test_cocci or args.profile_cocci
+ test_cocci = args.test_cocci or args.profile_cocci or args.prove_cocci
+ # We don't skip all patches for SmPL proof, we need to use its old series
+ skip_patches = args.profile_cocci or args.test_cocci
test_cocci_found = False
+ prove_cocci_tmp_dir = ''
+ if args.prove_cocci:
+ test_cocci = test_cocci.split('/')[-1]
+ prove_cocci_tmp_dir = target_dir + '.orig'
+ shutil.rmtree(prove_cocci_tmp_dir, ignore_errors=True)
+ copytree(target_dir, prove_cocci_tmp_dir)
patches = []
sempatches = []
for root, dirs, files in os.walk(os.path.join(source_dir, patch_src)):
for f in files:
- if not test_cocci and f.endswith('.patch'):
- patches.append(os.path.join(root, f))
+ if not skip_patches and f.endswith('.patch'):
+ if args.prove_cocci:
+ # As an example if you use --prove-cocci patches/collateral-evolutions/network/09-threaded-irq.cocci
+ # the patches under 09-threaded-irq will be used for the proof.
+ proof_to_test_dir = test_cocci.split('/')[-1].split('.cocci')[0]
+ if proof_to_test_dir in os.path.join(root, f):
+ logwrite("Aggregating patch for Coccinelle SmPL %s proof: %s" % (proof_to_test_dir, f))
+ patches.append(os.path.join(root, f))
+ else:
+ patches.append(os.path.join(root, f))
if f.endswith('.cocci'):
if test_cocci:
if f not in test_cocci:
@@ -502,6 +518,8 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
logwrite("Testing Coccinelle SmPL patch: %s" % test_cocci)
elif args.profile_cocci:
logwrite("Profiling Coccinelle SmPL patch: %s" % test_cocci)
+ elif args.prove_cocci:
+ logwrite("Proving Coccinelle SmPL patch: %s" % test_cocci)
sempatches.append(os.path.join(root, f))
patches.sort()
prefix_len = len(os.path.join(source_dir, patch_src)) + 1
@@ -533,10 +551,13 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
fullfn = os.path.join(target_dir, patched_file)
shutil.copyfile(fullfn, fullfn + '.orig_file')
+ patch_target_dir = target_dir
+ if args.prove_cocci:
+ patch_target_dir = prove_cocci_tmp_dir
process = subprocess.Popen(['patch', '-p1'], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
close_fds=True, universal_newlines=True,
- cwd=target_dir)
+ cwd=patch_target_dir)
output = process.communicate(input=open(pfile, 'r').read())[0]
output = output.split('\n')
if output[-1] == '':
@@ -578,7 +599,13 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
for f in files:
if f[-5:] == '.orig' or f[-4:] == '.rej':
os.unlink(os.path.join(root, f))
- git_debug_snapshot(args, "apply %s patch %s" % (desc, print_name))
+ if patch_target_dir != target_dir:
+ for root, dirs, files in os.walk(patch_target_dir):
+ for f in files:
+ if f[-5:] == '.orig' or f[-4:] == '.rej':
+ os.unlink(os.path.join(root, f))
+ if not args.prove_cocci:
+ git_debug_snapshot(args, "apply %s patch %s" % (desc, print_name))
sempatches.sort()
prefix_len = len(os.path.join(source_dir, patch_src)) + 1
@@ -615,8 +642,27 @@ def apply_patches(args, desc, source_dir, patch_src, target_dir, logwrite=lambda
for f in files:
if f.endswith('.cocci_backup'):
os.unlink(os.path.join(root, f))
+ if patch_target_dir != target_dir:
+ for root, dirs, files in os.walk(patch_target_dir):
+ for f in files:
+ if f.endswith('.cocci_backup'):
+ os.unlink(os.path.join(root, f))
git_debug_snapshot(args, "apply %s SmPL patch %s" % (desc, print_name))
+ if args.prove_cocci:
+ copytree(prove_cocci_tmp_dir, target_dir, ignore=shutil.ignore_patterns('.git'))
+ shutil.rmtree(prove_cocci_tmp_dir, ignore_errors=True)
+ diff_stat = git.diff(tree=target_dir, extra_args=['--stat'])
+ if len(diff_stat) == 0:
+ logwrite('\nSmPL patch fully replaces patch series')
+ else:
+ logwrite('\nReview the difference between what the tree looks like ')
+ logwrite('by applying your SmPL patch, then reverting that and ')
+ logwrite('only applying your the patches in the patch series.')
+ logwrite('')
+ logwrite('Change directory to %s and run \'git diff\'' % target_dir)
+ logwrite('diff stat of the changes:\n')
+ logwrite(diff_stat)
if test_cocci and test_cocci_found:
logwrite('Done!')
sys.exit(0)
@@ -675,6 +721,11 @@ def _main():
help='Only use the cocci file passed and pass --profile to Coccinelle, ' +
'also creates a git repo on the target directory for easy inspection ' +
'of changes done by Coccinelle.')
+ parser.add_argument('--prove-cocci', metavar='<sp_file>', type=str, default=None,
+ help='Only use the cocci file passed for Coccinelle and prove that it provides ' +
+ 'sufficient replacement for the patches under similar path name. Running ' +
+ 'git diff on the target directory suffices to show you what extra things' +
+ 'your SmPL patch did or what it didn\'t cover.')
args = parser.parse_args()
# When building a package we use CPTCFG as we can rely on the
@@ -721,6 +772,7 @@ def _main():
kup_test=args.kup_test,
test_cocci=args.test_cocci,
profile_cocci=args.profile_cocci,
+ prove_cocci=args.prove_cocci,
logwrite=logwrite)
def process(kerneldir, copy_list_file, git_revision=None,
@@ -730,6 +782,7 @@ def process(kerneldir, copy_list_file, git_revision=None,
kup_test=False,
test_cocci=None,
profile_cocci=None,
+ prove_cocci=None,
logwrite=lambda x:None,
git_tracked_version=False):
class Args(object):
@@ -738,7 +791,8 @@ def process(kerneldir, copy_list_file, git_revision=None,
gitdebug, verbose, extra_driver, kup,
kup_test,
test_cocci,
- profile_cocci):
+ profile_cocci,
+ prove_cocci):
self.kerneldir = kerneldir
self.copy_list = copy_list_file
self.git_revision = git_revision
@@ -753,7 +807,8 @@ def process(kerneldir, copy_list_file, git_revision=None,
self.kup_test = kup_test
self.test_cocci = test_cocci
self.profile_cocci = profile_cocci
- if self.test_cocci or self.profile_cocci:
+ self.prove_cocci = prove_cocci
+ if self.test_cocci or self.profile_cocci or self.prove_cocci:
self.gitdebug = True
def git_paranoia(tree=None, logwrite=lambda x:None):
data = git.paranoia(tree)
@@ -767,7 +822,7 @@ def process(kerneldir, copy_list_file, git_revision=None,
args = Args(kerneldir, copy_list_file,
git_revision, bpid, clean, refresh, base_name,
gitdebug, verbose, extra_driver, kup, kup_test,
- test_cocci, profile_cocci)
+ test_cocci, profile_cocci, prove_cocci)
rel_prep = None
if bpid.integrate:
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
2015-06-06 0:10 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-06 12:12 ` Johannes Berg
-1 siblings, 0 replies; 26+ messages in thread
From: Johannes Berg @ 2015-06-06 12:12 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: backports, cocci
On Fri, 2015-06-05 at 17:10 -0700, Luis R. Rodriguez wrote:
> If you have an SmPL patch that you think is ready to replace
> a series of unified diff patches you can pass as an argument
> to gentree.py '--prove-cocci' with the cocci file as the
> an extra argument and gentree.py will try to prove equivalence
> between the unified diff series and your Coccinelle SmPL patch.
>
> You can use this as a guide when trying to replace an existing
> unified diff series carried within backports with a respective
> Coccinelle SmPL patch. You can use this to get a warm fuzzy or
> to provide backports maintainers with a warm fuzzy of comfort
> that your SmPL patch is sufficient.
I don't like this at all.
gentree.py is supposed to be a tool to generate a new backport tree.
You're (ab)using it for (s)patch development purposes that it was never
intended for.
It's already grown to be a spaghetti mess of different options, some of
which cause partial tree creation (or no proper tree creation at all,
iirc) and I think adding more to this will make it unmaintainable.
Additionally, there's no real reason why this needs to be part of
gentree. In theory, you can just apply both patches to any kind of tree
(doesn't have to be a backport) and see the difference.
In practice, I understand that it might make sense to apply them to a
backport tree because that's where the original patch (non-spatch) came
from, since presumably you want to use it for development. However, I
still think this is far enough from the original purpose just like
test_cocci and profile_cocci that it shouldn't be there.
I'd support changing gentree to support a "up to this patch" mode, in
which it stops processing at a certain patch and other scripts can then
do remaining work like cocci profiling (which IMHO really shouldn't be
here at all) or this comparison testing.
I can also see how adding more to this script is convenient, since it's
just a few lines of code in the right place in the script, but this has
already made it complicated to follow all the different code paths and
change them appropriately for any changes.
As a consequence, I cannot support this change and would much rather
remove more of the cocci test options from here - really something like
profiling and equivalence testing should be part of a script provided by
upstream coccinelle anyway, instead of in the backports project.
johannes
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Cocci] [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
@ 2015-06-06 12:12 ` Johannes Berg
0 siblings, 0 replies; 26+ messages in thread
From: Johannes Berg @ 2015-06-06 12:12 UTC (permalink / raw)
To: cocci
On Fri, 2015-06-05 at 17:10 -0700, Luis R. Rodriguez wrote:
> If you have an SmPL patch that you think is ready to replace
> a series of unified diff patches you can pass as an argument
> to gentree.py '--prove-cocci' with the cocci file as the
> an extra argument and gentree.py will try to prove equivalence
> between the unified diff series and your Coccinelle SmPL patch.
>
> You can use this as a guide when trying to replace an existing
> unified diff series carried within backports with a respective
> Coccinelle SmPL patch. You can use this to get a warm fuzzy or
> to provide backports maintainers with a warm fuzzy of comfort
> that your SmPL patch is sufficient.
I don't like this at all.
gentree.py is supposed to be a tool to generate a new backport tree.
You're (ab)using it for (s)patch development purposes that it was never
intended for.
It's already grown to be a spaghetti mess of different options, some of
which cause partial tree creation (or no proper tree creation at all,
iirc) and I think adding more to this will make it unmaintainable.
Additionally, there's no real reason why this needs to be part of
gentree. In theory, you can just apply both patches to any kind of tree
(doesn't have to be a backport) and see the difference.
In practice, I understand that it might make sense to apply them to a
backport tree because that's where the original patch (non-spatch) came
from, since presumably you want to use it for development. However, I
still think this is far enough from the original purpose just like
test_cocci and profile_cocci that it shouldn't be there.
I'd support changing gentree to support a "up to this patch" mode, in
which it stops processing at a certain patch and other scripts can then
do remaining work like cocci profiling (which IMHO really shouldn't be
here at all) or this comparison testing.
I can also see how adding more to this script is convenient, since it's
just a few lines of code in the right place in the script, but this has
already made it complicated to follow all the different code paths and
change them appropriately for any changes.
As a consequence, I cannot support this change and would much rather
remove more of the cocci test options from here - really something like
profiling and equivalence testing should be part of a script provided by
upstream coccinelle anyway, instead of in the backports project.
johannes
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
2015-06-06 12:12 ` [Cocci] " Johannes Berg
@ 2015-06-08 19:31 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-08 19:31 UTC (permalink / raw)
To: Johannes Berg; +Cc: backports@vger.kernel.org, cocci@systeme.lip6.fr
On Sat, Jun 6, 2015 at 5:12 AM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Fri, 2015-06-05 at 17:10 -0700, Luis R. Rodriguez wrote:
>> If you have an SmPL patch that you think is ready to replace
>> a series of unified diff patches you can pass as an argument
>> to gentree.py '--prove-cocci' with the cocci file as the
>> an extra argument and gentree.py will try to prove equivalence
>> between the unified diff series and your Coccinelle SmPL patch.
>>
>> You can use this as a guide when trying to replace an existing
>> unified diff series carried within backports with a respective
>> Coccinelle SmPL patch. You can use this to get a warm fuzzy or
>> to provide backports maintainers with a warm fuzzy of comfort
>> that your SmPL patch is sufficient.
>
> I don't like this at all.
>
> gentree.py is supposed to be a tool to generate a new backport tree.
> You're (ab)using it for (s)patch development purposes that it was never
> intended for.
This is true, its in the like of how we wrote pycocci to provide us
with a multithreaded solution for spatch integration / development as
well and how pycocci now is upstream on Coccinelle. That will / can be
used until Coccinelle completes integration of wrapping up its
multithreaded solution in a slightly different way.
> It's already grown to be a spaghetti mess of different options, some of
> which cause partial tree creation (or no proper tree creation at all,
> iirc) and I think adding more to this will make it unmaintainable.
Yeah I can see that, it might already be pretty complex as-is.
> Additionally, there's no real reason why this needs to be part of
> gentree. In theory, you can just apply both patches to any kind of tree
> (doesn't have to be a backport) and see the difference.
Indeed, my original goal was to generalize this but I just never got
to it. I had a need for this again now, so I rebased it based on an
old patch.
> In practice, I understand that it might make sense to apply them to a
> backport tree because that's where the original patch (non-spatch) came
> from, since presumably you want to use it for development. However, I
> still think this is far enough from the original purpose just like
> test_cocci and profile_cocci that it shouldn't be there.
Sure, at least for this functionality the way it handles series is
specialized to backports, ie, series-name-foo.cocci and assuming
their's an equivalent unified patch equivalent series under
series-name-foo/, but this can be generalized as part of a tool as
well.
> I'd support changing gentree to support a "up to this patch" mode, in
> which it stops processing at a certain patch and other scripts can then
> do remaining work like cocci profiling (which IMHO really shouldn't be
> here at all) or this comparison testing.
OK sure, agreed.
> I can also see how adding more to this script is convenient, since it's
> just a few lines of code in the right place in the script, but this has
> already made it complicated to follow all the different code paths and
> change them appropriately for any changes.
Agreed.
> As a consequence, I cannot support this change and would much rather
> remove more of the cocci test options from here - really something like
> profiling and equivalence testing should be part of a script provided by
> upstream coccinelle anyway, instead of in the backports project.
--test-cocci provides the similar functionality as you describe above
to "stop after", in this case its just "apply only this series".
Perhaps --test-cocci should be replaced with --only-this-series or
something like that and/or --stop-on-series. Both would suffice for an
external tool to them go and do the tests we need.
In so far as where else to put this functionality into, since pycocci
is now part of Coccinelle, I could try to put that there.
I won't merge this then but I will note that I find this extremely
useful for spatch development, I am not sure when I'll get time to
integrate into pycocci which is why for convenience purpose did the
respin. Folks who want this will just have to take this patch on their
own and use it until we implement this into Coccinelle somehow
directly (pycocci or others).
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Cocci] [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
@ 2015-06-08 19:31 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-08 19:31 UTC (permalink / raw)
To: cocci
On Sat, Jun 6, 2015 at 5:12 AM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Fri, 2015-06-05 at 17:10 -0700, Luis R. Rodriguez wrote:
>> If you have an SmPL patch that you think is ready to replace
>> a series of unified diff patches you can pass as an argument
>> to gentree.py '--prove-cocci' with the cocci file as the
>> an extra argument and gentree.py will try to prove equivalence
>> between the unified diff series and your Coccinelle SmPL patch.
>>
>> You can use this as a guide when trying to replace an existing
>> unified diff series carried within backports with a respective
>> Coccinelle SmPL patch. You can use this to get a warm fuzzy or
>> to provide backports maintainers with a warm fuzzy of comfort
>> that your SmPL patch is sufficient.
>
> I don't like this at all.
>
> gentree.py is supposed to be a tool to generate a new backport tree.
> You're (ab)using it for (s)patch development purposes that it was never
> intended for.
This is true, its in the like of how we wrote pycocci to provide us
with a multithreaded solution for spatch integration / development as
well and how pycocci now is upstream on Coccinelle. That will / can be
used until Coccinelle completes integration of wrapping up its
multithreaded solution in a slightly different way.
> It's already grown to be a spaghetti mess of different options, some of
> which cause partial tree creation (or no proper tree creation at all,
> iirc) and I think adding more to this will make it unmaintainable.
Yeah I can see that, it might already be pretty complex as-is.
> Additionally, there's no real reason why this needs to be part of
> gentree. In theory, you can just apply both patches to any kind of tree
> (doesn't have to be a backport) and see the difference.
Indeed, my original goal was to generalize this but I just never got
to it. I had a need for this again now, so I rebased it based on an
old patch.
> In practice, I understand that it might make sense to apply them to a
> backport tree because that's where the original patch (non-spatch) came
> from, since presumably you want to use it for development. However, I
> still think this is far enough from the original purpose just like
> test_cocci and profile_cocci that it shouldn't be there.
Sure, at least for this functionality the way it handles series is
specialized to backports, ie, series-name-foo.cocci and assuming
their's an equivalent unified patch equivalent series under
series-name-foo/, but this can be generalized as part of a tool as
well.
> I'd support changing gentree to support a "up to this patch" mode, in
> which it stops processing at a certain patch and other scripts can then
> do remaining work like cocci profiling (which IMHO really shouldn't be
> here at all) or this comparison testing.
OK sure, agreed.
> I can also see how adding more to this script is convenient, since it's
> just a few lines of code in the right place in the script, but this has
> already made it complicated to follow all the different code paths and
> change them appropriately for any changes.
Agreed.
> As a consequence, I cannot support this change and would much rather
> remove more of the cocci test options from here - really something like
> profiling and equivalence testing should be part of a script provided by
> upstream coccinelle anyway, instead of in the backports project.
--test-cocci provides the similar functionality as you describe above
to "stop after", in this case its just "apply only this series".
Perhaps --test-cocci should be replaced with --only-this-series or
something like that and/or --stop-on-series. Both would suffice for an
external tool to them go and do the tests we need.
In so far as where else to put this functionality into, since pycocci
is now part of Coccinelle, I could try to put that there.
I won't merge this then but I will note that I find this extremely
useful for spatch development, I am not sure when I'll get time to
integrate into pycocci which is why for convenience purpose did the
respin. Folks who want this will just have to take this patch on their
own and use it until we implement this into Coccinelle somehow
directly (pycocci or others).
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
2015-06-08 19:31 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-08 19:45 ` Johannes Berg
-1 siblings, 0 replies; 26+ messages in thread
From: Johannes Berg @ 2015-06-08 19:45 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: backports@vger.kernel.org, cocci@systeme.lip6.fr
On Mon, 2015-06-08 at 12:31 -0700, Luis R. Rodriguez wrote:
> This is true, its in the like of how we wrote pycocci to provide us
> with a multithreaded solution for spatch integration / development as
> well and how pycocci now is upstream on Coccinelle.
Speaking of which - are you aware that pycocci fails (or rather doesn't
fail!) miserably when cocci isn't installed/in the $PATH? At least I got
a report to that extent, that it didn't really complete nor report an
error in that case.
johannes
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Cocci] [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
@ 2015-06-08 19:45 ` Johannes Berg
0 siblings, 0 replies; 26+ messages in thread
From: Johannes Berg @ 2015-06-08 19:45 UTC (permalink / raw)
To: cocci
On Mon, 2015-06-08 at 12:31 -0700, Luis R. Rodriguez wrote:
> This is true, its in the like of how we wrote pycocci to provide us
> with a multithreaded solution for spatch integration / development as
> well and how pycocci now is upstream on Coccinelle.
Speaking of which - are you aware that pycocci fails (or rather doesn't
fail!) miserably when cocci isn't installed/in the $PATH? At least I got
a report to that extent, that it didn't really complete nor report an
error in that case.
johannes
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
2015-06-08 19:45 ` [Cocci] " Johannes Berg
@ 2015-06-08 20:08 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-08 20:08 UTC (permalink / raw)
To: Johannes Berg; +Cc: backports@vger.kernel.org, cocci@systeme.lip6.fr
On Mon, Jun 8, 2015 at 12:45 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Mon, 2015-06-08 at 12:31 -0700, Luis R. Rodriguez wrote:
>
>> This is true, its in the like of how we wrote pycocci to provide us
>> with a multithreaded solution for spatch integration / development as
>> well and how pycocci now is upstream on Coccinelle.
>
> Speaking of which - are you aware that pycocci fails (or rather doesn't
> fail!) miserably when cocci isn't installed/in the $PATH? At least I got
> a report to that extent,
Did you verify it?
> that it didn't really complete nor report an error in that case.
Definitely not. Error reporting from pycocci's use of Coccinelle use
sucked though because it was adding extra spaces in between each
character though, I just fixed that last week, will sync now. Patches
/ reports for issues are welcome but please note that pycocci is now
part of Coccinelle so issues / patches should copy that list. For a
while I'll just keep these in sync for convenience given that
Coccinelle tends to batch a few commits before a release is made. I'll
sync up now though.
mcgrof@ergon ~/linux-next (git::20150604-proto_ops-send-rcv-smpl)$ which pycocci
which: no pycocci in
(/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/home/mcgrof/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games)
So not on my path.
mcgrof@ergon ~/linux-next (git::20150604-proto_ops-send-rcv-smpl)$
/home/mcgrof/devel/coccinelle/tools/pycocci 0002-no_dmabuf.cocci
drivers/media/v4l2-core/videobuf2-dma-contig.c
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 0
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 1
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 2
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 3
and git diff yields exact same results as if when pycocci is in my
path. Please have the user report the issue to this list and copy the
cocci list. Also Johannes, I value your time and I feel you're
investing quite a bit of time into this NACK discussion, I obviously
trust your judgement completely on gentree.py maintenance so for your
convenience feel free to be concise in your NACK's for patches there.
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Cocci] [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
@ 2015-06-08 20:08 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-08 20:08 UTC (permalink / raw)
To: cocci
On Mon, Jun 8, 2015 at 12:45 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Mon, 2015-06-08 at 12:31 -0700, Luis R. Rodriguez wrote:
>
>> This is true, its in the like of how we wrote pycocci to provide us
>> with a multithreaded solution for spatch integration / development as
>> well and how pycocci now is upstream on Coccinelle.
>
> Speaking of which - are you aware that pycocci fails (or rather doesn't
> fail!) miserably when cocci isn't installed/in the $PATH? At least I got
> a report to that extent,
Did you verify it?
> that it didn't really complete nor report an error in that case.
Definitely not. Error reporting from pycocci's use of Coccinelle use
sucked though because it was adding extra spaces in between each
character though, I just fixed that last week, will sync now. Patches
/ reports for issues are welcome but please note that pycocci is now
part of Coccinelle so issues / patches should copy that list. For a
while I'll just keep these in sync for convenience given that
Coccinelle tends to batch a few commits before a release is made. I'll
sync up now though.
mcgrof at ergon ~/linux-next (git::20150604-proto_ops-send-rcv-smpl)$ which pycocci
which: no pycocci in
(/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/home/mcgrof/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games)
So not on my path.
mcgrof at ergon ~/linux-next (git::20150604-proto_ops-send-rcv-smpl)$
/home/mcgrof/devel/coccinelle/tools/pycocci 0002-no_dmabuf.cocci
drivers/media/v4l2-core/videobuf2-dma-contig.c
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 0
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 1
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 2
spatch --sp-file 0002-no_dmabuf.cocci --in-place --recursive-includes
--relax-include-path --use-coccigrep --timeout 120 --dir
drivers/media/v4l2-core/videobuf2-dma-contig.c -max 4 -index 3
and git diff yields exact same results as if when pycocci is in my
path. Please have the user report the issue to this list and copy the
cocci list. Also Johannes, I value your time and I feel you're
investing quite a bit of time into this NACK discussion, I obviously
trust your judgement completely on gentree.py maintenance so for your
convenience feel free to be concise in your NACK's for patches there.
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
2015-06-08 20:08 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-08 20:29 ` Johannes Berg
-1 siblings, 0 replies; 26+ messages in thread
From: Johannes Berg @ 2015-06-08 20:29 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: backports@vger.kernel.org, cocci@systeme.lip6.fr
On Mon, 2015-06-08 at 13:08 -0700, Luis R. Rodriguez wrote:
> > Speaking of which - are you aware that pycocci fails (or rather doesn't
> > fail!) miserably when cocci isn't installed/in the $PATH? At least I got
> > a report to that extent,
>
> Did you verify it?
No, sorry. It was actually a pretty old discussion that came to my mind
now.
> mcgrof@ergon ~/linux-next (git::20150604-proto_ops-send-rcv-smpl)$ which pycocci
> which: no pycocci in
> (/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/home/mcgrof/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games)
>
> So not on my path.
Ah, no, I meant if *spatch* isn't on the $PATH, but you call pycocci ...
the report said that in that case pycocci wasn't really failing
"gracefully".
Anyway - I really should verify that myself first.
> Also Johannes, I value your time and I feel you're
> investing quite a bit of time into this NACK discussion, I obviously
> trust your judgement completely on gentree.py maintenance so for your
> convenience feel free to be concise in your NACK's for patches there.
Nah, don't worry -- I need to write it down to actually have a coherent
argument myself :)
johannes
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Cocci] [PATCH 3/4] gentree.py: add SmPL patch equivalence proof support
@ 2015-06-08 20:29 ` Johannes Berg
0 siblings, 0 replies; 26+ messages in thread
From: Johannes Berg @ 2015-06-08 20:29 UTC (permalink / raw)
To: cocci
On Mon, 2015-06-08 at 13:08 -0700, Luis R. Rodriguez wrote:
> > Speaking of which - are you aware that pycocci fails (or rather doesn't
> > fail!) miserably when cocci isn't installed/in the $PATH? At least I got
> > a report to that extent,
>
> Did you verify it?
No, sorry. It was actually a pretty old discussion that came to my mind
now.
> mcgrof at ergon ~/linux-next (git::20150604-proto_ops-send-rcv-smpl)$ which pycocci
> which: no pycocci in
> (/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/usr/local/bin/:/usr/local/sbin/:/sbin/:/usr/sbin/:/home/mcgrof/bin/:/usr/bin:/home/mcgrof/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games)
>
> So not on my path.
Ah, no, I meant if *spatch* isn't on the $PATH, but you call pycocci ...
the report said that in that case pycocci wasn't really failing
"gracefully".
Anyway - I really should verify that myself first.
> Also Johannes, I value your time and I feel you're
> investing quite a bit of time into this NACK discussion, I obviously
> trust your judgement completely on gentree.py maintenance so for your
> convenience feel free to be concise in your NACK's for patches there.
Nah, don't worry -- I need to write it down to actually have a coherent
argument myself :)
johannes
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 4/4] patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
2015-06-06 0:09 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-06 0:10 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:10 UTC (permalink / raw)
To: backports; +Cc: cocci, Luis R. Rodriguez
This replaces the 436 line of unified diff with 152
lines of grammar Coccinelle SmPL patch. SmPL patch
equivalence proof tests reveals only cosmetic changes
between using Coccinelle SmPL and unified diff as shown
below. The difference shown are the results of two
trees, one in which we applied the SmPL patch, and another
in which the old unified patch series were used. This
gives us an idea of what Coccinelle did differently.
1 3.0.101 [ OK ]
2 3.1.10 [ OK ]
3 3.2.68 [ OK ]
4 3.3.8 [ OK ]
5 3.4.107 [ OK ]
6 3.5.7 [ OK ]
7 3.6.11 [ OK ]
8 3.7.10 [ OK ]
9 3.8.13 [ OK ]
10 3.9.11 [ OK ]
11 3.10.75 [ OK ]
12 3.11.10 [ OK ]
13 3.12.40 [ OK ]
14 3.13.11 [ OK ]
15 3.14.39 [ OK ]
16 3.15.10 [ OK ]
17 3.16.7 [ OK ]
18 3.17.8 [ OK ]
19 3.18.12 [ OK ]
20 3.19.5 [ OK ]
21 4.0.0 [ OK ]
22 4.1-rc1 [ OK ]
mcgrof@ergon ~/backports (git::master)$ time \
./gentree.py --clean --prove-cocci \
patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci \
/home/mcgrof/linux-next/ /home/mcgrof/build/backports-20150525
Copy original source files ...
Applying patches from patches to
/home/mcgrof/build/backports-20150525 ...
Proving Coccinelle SmPL patch: 0054-struct-proto_ops-sig.cocci
Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: ieee802154.patch
Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: nfc.patch
Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: bluetooth.patch
Review the difference between what the tree looks like
by applying your SmPL patch, then reverting that and
only applying your the patches in the patch series.
Change directory to /home/mcgrof/build/backports-20150525 and run 'git diff'
diff stat of the changes:
net/bluetooth/hci_sock.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Done!
real 0m21.965s
user 0m45.947s
sys 0m4.072s
Now when I change directory to /home/mcgrof/build/backports-20150525 and
run 'git diff' I get:
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 9326bc8..9ca0166 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -956,7 +956,8 @@ static int hci_sock_recvmsg(struct socket *sock,
struct msghdr *msg, size_t len,
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket
*sock,
struct msghdr *msg, size_t len,
- int flags){
+ int flags)
+{
return hci_sock_recvmsg(sock, msg, len, flags);
}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
@@ -1198,7 +1199,8 @@ drop:
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket
*sock,
- struct msghdr *msg, size_t len){
+ struct msghdr *msg, size_t len)
+{
return hci_sock_sendmsg(sock, msg, len);
}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
@@ -1360,12 +1362,9 @@ static const struct proto_ops hci_sock_ops = {
.getname = hci_sock_getname,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
.sendmsg = hci_sock_sendmsg,
-#else
- .sendmsg = backport_hci_sock_sendmsg,
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
.recvmsg = hci_sock_recvmsg,
#else
+ .sendmsg = backport_hci_sock_sendmsg,
.recvmsg = backport_hci_sock_recvmsg,
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
.ioctl = hci_sock_ioctl,
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
.../network/0054-struct-proto_ops-sig.cocci | 177 +++++++++++++++++++
.../0054-struct-proto_ops-sig/bluetooth.patch | 187 ---------------------
.../0054-struct-proto_ops-sig/ieee802154.patch | 134 ---------------
.../network/0054-struct-proto_ops-sig/nfc.patch | 115 -------------
4 files changed, 177 insertions(+), 436 deletions(-)
create mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
new file mode 100644
index 0000000..0c0845a
--- /dev/null
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
@@ -0,0 +1,177 @@
+/*
+This provides the backport for the collateral evolution introduced
+via commit 1b784140474e4fc94281a49e96c67d29df0efbde, titled
+"net: Remove iocb argument from sendmsg and recvmsg".
+
+The net/tipc/ subsystem (Transparent Inter Process Communication (TIPC))
+relied historically on using an argument passed on the struct proto_ops
+and struct proto sendmsg and recvmsg callbacks to determine if it needed
+to perform a lock within its own code. Commit 1b784140474e4 removed replaced
+the locking functionality to require the argument and instead moved all
+the necessary heuristics into net/tipc. Other subsystems just passed NULL.
+After the net/tipc code was cleaned up from the locking (see commmit
+39a0295f901423e260a034ac7c3211ecaa9c2745 titled "tipc: Don't use iocb
+argument in socket layer") we no longer needed the extra argument on the
+struct proto_ops and struct proto callbacks.
+
+To backport non-tipc subsystems we then just need to modify the upstream
+code which declares these callbacks and add the extra argument again, but
+the same routine can be used from upstream code. The grammar we use below
+declares routines which can be pegged to struct proto_ops and struct proto
+callbacks that simply call the same upstream code, the extra argument is
+ignored. The argument can be ignored as it was only used within the
+net/tipc subsystem for locking purposes.
+*/
+
+@ proto_ops @
+identifier s, send_func, recv_func;
+@@
+
+ struct proto_ops s = {
+ .sendmsg = send_func,
+ .recvmsg = recv_func,
+};
+
+@ mod_send depends on proto_ops @
+identifier proto_ops.send_func;
+fresh identifier backport_send = "backport_" ## send_func;
+@@
+
+send_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_send(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
++{
++ return send_func(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_recv depends on proto_ops @
+identifier proto_ops.recv_func;
+fresh identifier backport_recv = "backport_" ## recv_func;
+@@
+
+recv_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_recv(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int flags)
++{
++ return recv_func(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_proto_ops_tx depends on proto_ops && mod_send @
+identifier s, proto_ops.send_func, mod_send.backport_send;
+@@
+
+ struct proto_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = send_func,
++#else
++ .sendmsg = backport_send,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_proto_ops_rx depends on proto_ops && mod_recv @
+identifier s, proto_ops.recv_func, mod_recv.backport_recv;
+@@
+
+ struct proto_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = recv_func,
++#else
++ .recvmsg = backport_recv,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_sock_send_callers depends on proto_ops@
+identifier proto_ops.send_func;
+identifier sock, msg, len, sk;
+@@
+
+send_func(struct socket *sock, struct msghdr *msg, size_t len)
+{
+ ...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ return sk->sk_prot->sendmsg(sk, msg, len);
++#else
++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+}
+
+@ proto @
+identifier s, send_func, recv_func;
+@@
+
+ struct proto s = {
+ .sendmsg = send_func,
+ .recvmsg = recv_func,
+};
+
+@ proto_mod_send depends on proto @
+identifier proto.send_func;
+fresh identifier backport_send = "backport_" ## send_func;
+@@
+
+send_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_send(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len)
++{
++ return send_func(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ proto_mod_recv depends on proto @
+identifier proto.recv_func;
+fresh identifier backport_recv = "backport_" ## recv_func;
+@@
+
+recv_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_recv(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int noblock, int flags, int *addr_len)
++{
++ return recv_func(sock, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_proto_tx depends on proto && proto_mod_send @
+identifier s, proto.send_func, proto_mod_send.backport_send;
+@@
+
+ struct proto s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = send_func,
++#else
++ .sendmsg = backport_send,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_proto_rx depends on proto && proto_mod_recv @
+identifier s, proto.recv_func, proto_mod_recv.backport_recv;
+@@
+
+ struct proto s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = recv_func,
++#else
++ .recvmsg = backport_recv,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
deleted file mode 100644
index 2cf5a9e..0000000
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
+++ /dev/null
@@ -1,187 +0,0 @@
---- a/net/bluetooth/hci_sock.c
-+++ b/net/bluetooth/hci_sock.c
-@@ -953,6 +953,14 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
-
- return err ? : copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags)
-+{
-+ return hci_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
- struct msghdr *msg, size_t msglen)
-@@ -1189,6 +1196,13 @@ drop:
- kfree_skb(skb);
- goto done;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+{
-+ return hci_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
- char __user *optval, unsigned int len)
-@@ -1345,8 +1358,13 @@ static const struct proto_ops hci_sock_ops = {
- .release = hci_sock_release,
- .bind = hci_sock_bind,
- .getname = hci_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = hci_sock_sendmsg,
- .recvmsg = hci_sock_recvmsg,
-+#else
-+ .sendmsg = backport_hci_sock_sendmsg,
-+ .recvmsg = backport_hci_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .ioctl = hci_sock_ioctl,
- .poll = datagram_poll,
- .listen = sock_no_listen,
---- a/net/bluetooth/l2cap_sock.c
-+++ b/net/bluetooth/l2cap_sock.c
-@@ -975,6 +975,13 @@ static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_l2cap_sock_sendmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return l2cap_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
-@@ -1036,6 +1043,14 @@ done:
- release_sock(sk);
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_l2cap_sock_recvmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return l2cap_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- /* Kill socket (only if zapped and orphan)
- * Must be called on unlocked socket.
-@@ -1618,8 +1633,16 @@ static const struct proto_ops l2cap_sock_ops = {
- .listen = l2cap_sock_listen,
- .accept = l2cap_sock_accept,
- .getname = l2cap_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = l2cap_sock_sendmsg,
-+#else
-+ .sendmsg = backport_l2cap_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = l2cap_sock_recvmsg,
-+#else
-+ .recvmsg = backport_l2cap_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .poll = bt_sock_poll,
- .ioctl = bt_sock_ioctl,
- .mmap = sock_no_mmap,
---- a/net/bluetooth/rfcomm/sock.c
-+++ b/net/bluetooth/rfcomm/sock.c
-@@ -622,6 +622,13 @@ done:
-
- return sent;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rfcomm_sock_sendmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return rfcomm_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t size, int flags)
-@@ -647,6 +654,14 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
-
- return len;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rfcomm_sock_recvmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return rfcomm_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
- {
-@@ -1044,8 +1059,16 @@ static const struct proto_ops rfcomm_sock_ops = {
- .listen = rfcomm_sock_listen,
- .accept = rfcomm_sock_accept,
- .getname = rfcomm_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = rfcomm_sock_sendmsg,
-+#else
-+ .sendmsg = backport_rfcomm_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = rfcomm_sock_recvmsg,
-+#else
-+ .recvmsg = backport_rfcomm_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .shutdown = rfcomm_sock_shutdown,
- .setsockopt = rfcomm_sock_setsockopt,
- .getsockopt = rfcomm_sock_getsockopt,
---- a/net/bluetooth/sco.c
-+++ b/net/bluetooth/sco.c
-@@ -713,6 +713,12 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- release_sock(sk);
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return sco_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
- {
-@@ -779,6 +785,13 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
-
- return bt_sock_recvmsg(sock, msg, len, flags);
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return sco_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
- {
-@@ -1178,8 +1191,16 @@ static const struct proto_ops sco_sock_ops = {
- .listen = sco_sock_listen,
- .accept = sco_sock_accept,
- .getname = sco_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = sco_sock_sendmsg,
-+#else
-+ .sendmsg = backport_sco_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = sco_sock_recvmsg,
-+#else
-+ .recvmsg = backport_sco_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .poll = bt_sock_poll,
- .ioctl = bt_sock_ioctl,
- .mmap = sock_no_mmap,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
deleted file mode 100644
index 0497dbe..0000000
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
+++ /dev/null
@@ -1,134 +0,0 @@
---- a/net/ieee802154/socket.c
-+++ b/net/ieee802154/socket.c
-@@ -101,8 +101,19 @@ static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- {
- struct sock *sk = sock->sk;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- return sk->sk_prot->sendmsg(sk, msg, len);
-+#else
-+ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_ieee802154_sock_sendmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return ieee802154_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
- int addr_len)
-@@ -323,6 +334,12 @@ out_dev:
- out:
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_raw_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return raw_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
- int noblock, int flags, int *addr_len)
-@@ -356,6 +373,13 @@ out:
- return err;
- return copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_raw_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int noblock,
-+ int flags, int *addr_len){
-+ return raw_recvmsg(sock, msg, len, noblock, flags, addr_len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
- {
-@@ -409,8 +433,16 @@ static struct proto ieee802154_raw_prot = {
- .obj_size = sizeof(struct sock),
- .close = raw_close,
- .bind = raw_bind,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = raw_sendmsg,
-+#else
-+ .sendmsg = backport_raw_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = raw_recvmsg,
-+#else
-+ .recvmsg = backport_raw_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .hash = raw_hash,
- .unhash = raw_unhash,
- .connect = raw_connect,
-@@ -434,7 +466,11 @@ static const struct proto_ops ieee802154_raw_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = sock_common_setsockopt,
- .getsockopt = sock_common_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = ieee802154_sock_sendmsg,
-+#else
-+ .sendmsg = backport_ieee802154_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .recvmsg = sock_common_recvmsg,
- .mmap = sock_no_mmap,
- .sendpage = sock_no_sendpage,
-@@ -710,6 +746,12 @@ out_dev:
- out:
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_dgram_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return dgram_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
- int noblock, int flags, int *addr_len)
-@@ -751,6 +793,13 @@ out:
- return err;
- return copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int noblock,
-+ int flags, int *addr_len){
-+ return dgram_recvmsg(sock, msg, len, noblock, flags, addr_len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
- {
-@@ -947,8 +996,16 @@ static struct proto ieee802154_dgram_prot = {
- .init = dgram_init,
- .close = dgram_close,
- .bind = dgram_bind,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = dgram_sendmsg,
-+#else
-+ .sendmsg = backport_dgram_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = dgram_recvmsg,
-+#else
-+ .recvmsg = backport_dgram_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .hash = dgram_hash,
- .unhash = dgram_unhash,
- .connect = dgram_connect,
-@@ -973,7 +1030,11 @@ static const struct proto_ops ieee802154_dgram_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = sock_common_setsockopt,
- .getsockopt = sock_common_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = ieee802154_sock_sendmsg,
-+#else
-+ .sendmsg = backport_ieee802154_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .recvmsg = sock_common_recvmsg,
- .mmap = sock_no_mmap,
- .sendpage = sock_no_sendpage,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
deleted file mode 100644
index e29c4d8..0000000
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
+++ /dev/null
@@ -1,115 +0,0 @@
---- a/net/nfc/llcp_sock.c
-+++ b/net/nfc/llcp_sock.c
-@@ -792,6 +792,12 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-
- return nfc_llcp_send_i_frame(llcp_sock, msg, len);
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return llcp_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
-@@ -882,6 +888,13 @@ done:
-
- return copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return llcp_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static const struct proto_ops llcp_sock_ops = {
- .family = PF_NFC,
-@@ -898,8 +911,16 @@ static const struct proto_ops llcp_sock_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = nfc_llcp_setsockopt,
- .getsockopt = nfc_llcp_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = llcp_sock_sendmsg,
-+#else
-+ .sendmsg = backport_llcp_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = llcp_sock_recvmsg,
-+#else
-+ .recvmsg = backport_llcp_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
-@@ -919,7 +940,11 @@ static const struct proto_ops llcp_rawsock_ops = {
- .setsockopt = sock_no_setsockopt,
- .getsockopt = sock_no_getsockopt,
- .sendmsg = sock_no_sendmsg,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = llcp_sock_recvmsg,
-+#else
-+ .recvmsg = backport_llcp_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
---- a/net/nfc/rawsock.c
-+++ b/net/nfc/rawsock.c
-@@ -246,6 +246,12 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
-
- return len;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return rawsock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags)
-@@ -274,6 +280,12 @@ static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
-
- return rc ? : copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags){
-+ return rawsock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static const struct proto_ops rawsock_ops = {
- .family = PF_NFC,
-@@ -290,8 +302,16 @@ static const struct proto_ops rawsock_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = sock_no_setsockopt,
- .getsockopt = sock_no_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = rawsock_sendmsg,
-+#else
-+ .sendmsg = backport_rawsock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = rawsock_recvmsg,
-+#else
-+ .recvmsg = backport_rawsock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
-@@ -311,7 +331,11 @@ static const struct proto_ops rawsock_raw_ops = {
- .setsockopt = sock_no_setsockopt,
- .getsockopt = sock_no_getsockopt,
- .sendmsg = sock_no_sendmsg,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = rawsock_recvmsg,
-+#else
-+ .recvmsg = backport_rawsock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread* [Cocci] [PATCH 4/4] patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
@ 2015-06-06 0:10 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-06 0:10 UTC (permalink / raw)
To: cocci
This replaces the 436 line of unified diff with 152
lines of grammar Coccinelle SmPL patch. SmPL patch
equivalence proof tests reveals only cosmetic changes
between using Coccinelle SmPL and unified diff as shown
below. The difference shown are the results of two
trees, one in which we applied the SmPL patch, and another
in which the old unified patch series were used. This
gives us an idea of what Coccinelle did differently.
1 3.0.101 [ OK ]
2 3.1.10 [ OK ]
3 3.2.68 [ OK ]
4 3.3.8 [ OK ]
5 3.4.107 [ OK ]
6 3.5.7 [ OK ]
7 3.6.11 [ OK ]
8 3.7.10 [ OK ]
9 3.8.13 [ OK ]
10 3.9.11 [ OK ]
11 3.10.75 [ OK ]
12 3.11.10 [ OK ]
13 3.12.40 [ OK ]
14 3.13.11 [ OK ]
15 3.14.39 [ OK ]
16 3.15.10 [ OK ]
17 3.16.7 [ OK ]
18 3.17.8 [ OK ]
19 3.18.12 [ OK ]
20 3.19.5 [ OK ]
21 4.0.0 [ OK ]
22 4.1-rc1 [ OK ]
mcgrof at ergon ~/backports (git::master)$ time \
./gentree.py --clean --prove-cocci \
patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci \
/home/mcgrof/linux-next/ /home/mcgrof/build/backports-20150525
Copy original source files ...
Applying patches from patches to
/home/mcgrof/build/backports-20150525 ...
Proving Coccinelle SmPL patch: 0054-struct-proto_ops-sig.cocci
Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: ieee802154.patch
Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: nfc.patch
Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: bluetooth.patch
Review the difference between what the tree looks like
by applying your SmPL patch, then reverting that and
only applying your the patches in the patch series.
Change directory to /home/mcgrof/build/backports-20150525 and run 'git diff'
diff stat of the changes:
net/bluetooth/hci_sock.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Done!
real 0m21.965s
user 0m45.947s
sys 0m4.072s
Now when I change directory to /home/mcgrof/build/backports-20150525 and
run 'git diff' I get:
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 9326bc8..9ca0166 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -956,7 +956,8 @@ static int hci_sock_recvmsg(struct socket *sock,
struct msghdr *msg, size_t len,
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket
*sock,
struct msghdr *msg, size_t len,
- int flags){
+ int flags)
+{
return hci_sock_recvmsg(sock, msg, len, flags);
}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
@@ -1198,7 +1199,8 @@ drop:
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket
*sock,
- struct msghdr *msg, size_t len){
+ struct msghdr *msg, size_t len)
+{
return hci_sock_sendmsg(sock, msg, len);
}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
@@ -1360,12 +1362,9 @@ static const struct proto_ops hci_sock_ops = {
.getname = hci_sock_getname,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
.sendmsg = hci_sock_sendmsg,
-#else
- .sendmsg = backport_hci_sock_sendmsg,
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
.recvmsg = hci_sock_recvmsg,
#else
+ .sendmsg = backport_hci_sock_sendmsg,
.recvmsg = backport_hci_sock_recvmsg,
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
.ioctl = hci_sock_ioctl,
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
.../network/0054-struct-proto_ops-sig.cocci | 177 +++++++++++++++++++
.../0054-struct-proto_ops-sig/bluetooth.patch | 187 ---------------------
.../0054-struct-proto_ops-sig/ieee802154.patch | 134 ---------------
.../network/0054-struct-proto_ops-sig/nfc.patch | 115 -------------
4 files changed, 177 insertions(+), 436 deletions(-)
create mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
new file mode 100644
index 0000000..0c0845a
--- /dev/null
+++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
@@ -0,0 +1,177 @@
+/*
+This provides the backport for the collateral evolution introduced
+via commit 1b784140474e4fc94281a49e96c67d29df0efbde, titled
+"net: Remove iocb argument from sendmsg and recvmsg".
+
+The net/tipc/ subsystem (Transparent Inter Process Communication (TIPC))
+relied historically on using an argument passed on the struct proto_ops
+and struct proto sendmsg and recvmsg callbacks to determine if it needed
+to perform a lock within its own code. Commit 1b784140474e4 removed replaced
+the locking functionality to require the argument and instead moved all
+the necessary heuristics into net/tipc. Other subsystems just passed NULL.
+After the net/tipc code was cleaned up from the locking (see commmit
+39a0295f901423e260a034ac7c3211ecaa9c2745 titled "tipc: Don't use iocb
+argument in socket layer") we no longer needed the extra argument on the
+struct proto_ops and struct proto callbacks.
+
+To backport non-tipc subsystems we then just need to modify the upstream
+code which declares these callbacks and add the extra argument again, but
+the same routine can be used from upstream code. The grammar we use below
+declares routines which can be pegged to struct proto_ops and struct proto
+callbacks that simply call the same upstream code, the extra argument is
+ignored. The argument can be ignored as it was only used within the
+net/tipc subsystem for locking purposes.
+*/
+
+@ proto_ops @
+identifier s, send_func, recv_func;
+@@
+
+ struct proto_ops s = {
+ .sendmsg = send_func,
+ .recvmsg = recv_func,
+};
+
+@ mod_send depends on proto_ops @
+identifier proto_ops.send_func;
+fresh identifier backport_send = "backport_" ## send_func;
+@@
+
+send_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_send(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
++{
++ return send_func(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_recv depends on proto_ops @
+identifier proto_ops.recv_func;
+fresh identifier backport_recv = "backport_" ## recv_func;
+@@
+
+recv_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_recv(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len, int flags)
++{
++ return recv_func(sock, msg, len, flags);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_proto_ops_tx depends on proto_ops && mod_send @
+identifier s, proto_ops.send_func, mod_send.backport_send;
+@@
+
+ struct proto_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = send_func,
++#else
++ .sendmsg = backport_send,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_proto_ops_rx depends on proto_ops && mod_recv @
+identifier s, proto_ops.recv_func, mod_recv.backport_recv;
+@@
+
+ struct proto_ops s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = recv_func,
++#else
++ .recvmsg = backport_recv,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_sock_send_callers depends on proto_ops@
+identifier proto_ops.send_func;
+identifier sock, msg, len, sk;
+@@
+
+send_func(struct socket *sock, struct msghdr *msg, size_t len)
+{
+ ...
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ return sk->sk_prot->sendmsg(sk, msg, len);
++#else
++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+}
+
+@ proto @
+identifier s, send_func, recv_func;
+@@
+
+ struct proto s = {
+ .sendmsg = send_func,
+ .recvmsg = recv_func,
+};
+
+@ proto_mod_send depends on proto @
+identifier proto.send_func;
+fresh identifier backport_send = "backport_" ## send_func;
+@@
+
+send_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_send(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len)
++{
++ return send_func(sock, msg, len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ proto_mod_recv depends on proto @
+identifier proto.recv_func;
+fresh identifier backport_recv = "backport_" ## recv_func;
+@@
+
+recv_func(...)
+{
+ ...
+}
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
++static int backport_recv(struct kiocb *iocb, struct socket *sock,
++ struct msghdr *msg, size_t len,
++ int noblock, int flags, int *addr_len)
++{
++ return recv_func(sock, msg, len, noblock, flags, addr_len);
++}
++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
+
+@ mod_proto_tx depends on proto && proto_mod_send @
+identifier s, proto.send_func, proto_mod_send.backport_send;
+@@
+
+ struct proto s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .sendmsg = send_func,
++#else
++ .sendmsg = backport_send,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
+
+@ mod_proto_rx depends on proto && proto_mod_recv @
+identifier s, proto.recv_func, proto_mod_recv.backport_recv;
+@@
+
+ struct proto s = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
+ .recvmsg = recv_func,
++#else
++ .recvmsg = backport_recv,
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
+};
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
deleted file mode 100644
index 2cf5a9e..0000000
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
+++ /dev/null
@@ -1,187 +0,0 @@
---- a/net/bluetooth/hci_sock.c
-+++ b/net/bluetooth/hci_sock.c
-@@ -953,6 +953,14 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
-
- return err ? : copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags)
-+{
-+ return hci_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
- struct msghdr *msg, size_t msglen)
-@@ -1189,6 +1196,13 @@ drop:
- kfree_skb(skb);
- goto done;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len)
-+{
-+ return hci_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
- char __user *optval, unsigned int len)
-@@ -1345,8 +1358,13 @@ static const struct proto_ops hci_sock_ops = {
- .release = hci_sock_release,
- .bind = hci_sock_bind,
- .getname = hci_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = hci_sock_sendmsg,
- .recvmsg = hci_sock_recvmsg,
-+#else
-+ .sendmsg = backport_hci_sock_sendmsg,
-+ .recvmsg = backport_hci_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .ioctl = hci_sock_ioctl,
- .poll = datagram_poll,
- .listen = sock_no_listen,
---- a/net/bluetooth/l2cap_sock.c
-+++ b/net/bluetooth/l2cap_sock.c
-@@ -975,6 +975,13 @@ static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_l2cap_sock_sendmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return l2cap_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
-@@ -1036,6 +1043,14 @@ done:
- release_sock(sk);
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_l2cap_sock_recvmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return l2cap_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- /* Kill socket (only if zapped and orphan)
- * Must be called on unlocked socket.
-@@ -1618,8 +1633,16 @@ static const struct proto_ops l2cap_sock_ops = {
- .listen = l2cap_sock_listen,
- .accept = l2cap_sock_accept,
- .getname = l2cap_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = l2cap_sock_sendmsg,
-+#else
-+ .sendmsg = backport_l2cap_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = l2cap_sock_recvmsg,
-+#else
-+ .recvmsg = backport_l2cap_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .poll = bt_sock_poll,
- .ioctl = bt_sock_ioctl,
- .mmap = sock_no_mmap,
---- a/net/bluetooth/rfcomm/sock.c
-+++ b/net/bluetooth/rfcomm/sock.c
-@@ -622,6 +622,13 @@ done:
-
- return sent;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rfcomm_sock_sendmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return rfcomm_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t size, int flags)
-@@ -647,6 +654,14 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
-
- return len;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rfcomm_sock_recvmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return rfcomm_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
- {
-@@ -1044,8 +1059,16 @@ static const struct proto_ops rfcomm_sock_ops = {
- .listen = rfcomm_sock_listen,
- .accept = rfcomm_sock_accept,
- .getname = rfcomm_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = rfcomm_sock_sendmsg,
-+#else
-+ .sendmsg = backport_rfcomm_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = rfcomm_sock_recvmsg,
-+#else
-+ .recvmsg = backport_rfcomm_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .shutdown = rfcomm_sock_shutdown,
- .setsockopt = rfcomm_sock_setsockopt,
- .getsockopt = rfcomm_sock_getsockopt,
---- a/net/bluetooth/sco.c
-+++ b/net/bluetooth/sco.c
-@@ -713,6 +713,12 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- release_sock(sk);
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return sco_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
- {
-@@ -779,6 +785,13 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
-
- return bt_sock_recvmsg(sock, msg, len, flags);
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return sco_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
- {
-@@ -1178,8 +1191,16 @@ static const struct proto_ops sco_sock_ops = {
- .listen = sco_sock_listen,
- .accept = sco_sock_accept,
- .getname = sco_sock_getname,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = sco_sock_sendmsg,
-+#else
-+ .sendmsg = backport_sco_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = sco_sock_recvmsg,
-+#else
-+ .recvmsg = backport_sco_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .poll = bt_sock_poll,
- .ioctl = bt_sock_ioctl,
- .mmap = sock_no_mmap,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
deleted file mode 100644
index 0497dbe..0000000
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
+++ /dev/null
@@ -1,134 +0,0 @@
---- a/net/ieee802154/socket.c
-+++ b/net/ieee802154/socket.c
-@@ -101,8 +101,19 @@ static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
- {
- struct sock *sk = sock->sk;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- return sk->sk_prot->sendmsg(sk, msg, len);
-+#else
-+ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_ieee802154_sock_sendmsg(struct kiocb *iocb,
-+ struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return ieee802154_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
- int addr_len)
-@@ -323,6 +334,12 @@ out_dev:
- out:
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_raw_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return raw_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
- int noblock, int flags, int *addr_len)
-@@ -356,6 +373,13 @@ out:
- return err;
- return copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_raw_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int noblock,
-+ int flags, int *addr_len){
-+ return raw_recvmsg(sock, msg, len, noblock, flags, addr_len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
- {
-@@ -409,8 +433,16 @@ static struct proto ieee802154_raw_prot = {
- .obj_size = sizeof(struct sock),
- .close = raw_close,
- .bind = raw_bind,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = raw_sendmsg,
-+#else
-+ .sendmsg = backport_raw_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = raw_recvmsg,
-+#else
-+ .recvmsg = backport_raw_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .hash = raw_hash,
- .unhash = raw_unhash,
- .connect = raw_connect,
-@@ -434,7 +466,11 @@ static const struct proto_ops ieee802154_raw_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = sock_common_setsockopt,
- .getsockopt = sock_common_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = ieee802154_sock_sendmsg,
-+#else
-+ .sendmsg = backport_ieee802154_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .recvmsg = sock_common_recvmsg,
- .mmap = sock_no_mmap,
- .sendpage = sock_no_sendpage,
-@@ -710,6 +746,12 @@ out_dev:
- out:
- return err;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_dgram_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return dgram_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
- int noblock, int flags, int *addr_len)
-@@ -751,6 +793,13 @@ out:
- return err;
- return copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int noblock,
-+ int flags, int *addr_len){
-+ return dgram_recvmsg(sock, msg, len, noblock, flags, addr_len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
- {
-@@ -947,8 +996,16 @@ static struct proto ieee802154_dgram_prot = {
- .init = dgram_init,
- .close = dgram_close,
- .bind = dgram_bind,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = dgram_sendmsg,
-+#else
-+ .sendmsg = backport_dgram_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = dgram_recvmsg,
-+#else
-+ .recvmsg = backport_dgram_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .hash = dgram_hash,
- .unhash = dgram_unhash,
- .connect = dgram_connect,
-@@ -973,7 +1030,11 @@ static const struct proto_ops ieee802154_dgram_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = sock_common_setsockopt,
- .getsockopt = sock_common_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = ieee802154_sock_sendmsg,
-+#else
-+ .sendmsg = backport_ieee802154_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .recvmsg = sock_common_recvmsg,
- .mmap = sock_no_mmap,
- .sendpage = sock_no_sendpage,
diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
deleted file mode 100644
index e29c4d8..0000000
--- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
+++ /dev/null
@@ -1,115 +0,0 @@
---- a/net/nfc/llcp_sock.c
-+++ b/net/nfc/llcp_sock.c
-@@ -792,6 +792,12 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
-
- return nfc_llcp_send_i_frame(llcp_sock, msg, len);
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return llcp_sock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
- size_t len, int flags)
-@@ -882,6 +888,13 @@ done:
-
- return copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len,
-+ int flags){
-+ return llcp_sock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static const struct proto_ops llcp_sock_ops = {
- .family = PF_NFC,
-@@ -898,8 +911,16 @@ static const struct proto_ops llcp_sock_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = nfc_llcp_setsockopt,
- .getsockopt = nfc_llcp_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = llcp_sock_sendmsg,
-+#else
-+ .sendmsg = backport_llcp_sock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = llcp_sock_recvmsg,
-+#else
-+ .recvmsg = backport_llcp_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
-@@ -919,7 +940,11 @@ static const struct proto_ops llcp_rawsock_ops = {
- .setsockopt = sock_no_setsockopt,
- .getsockopt = sock_no_getsockopt,
- .sendmsg = sock_no_sendmsg,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = llcp_sock_recvmsg,
-+#else
-+ .recvmsg = backport_llcp_sock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
---- a/net/nfc/rawsock.c
-+++ b/net/nfc/rawsock.c
-@@ -246,6 +246,12 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
-
- return len;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len){
-+ return rawsock_sendmsg(sock, msg, len);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
- int flags)
-@@ -274,6 +280,12 @@ static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
-
- return rc ? : copied;
- }
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-+static int backport_rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
-+ struct msghdr *msg, size_t len, int flags){
-+ return rawsock_recvmsg(sock, msg, len, flags);
-+}
-+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
-
- static const struct proto_ops rawsock_ops = {
- .family = PF_NFC,
-@@ -290,8 +302,16 @@ static const struct proto_ops rawsock_ops = {
- .shutdown = sock_no_shutdown,
- .setsockopt = sock_no_setsockopt,
- .getsockopt = sock_no_getsockopt,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .sendmsg = rawsock_sendmsg,
-+#else
-+ .sendmsg = backport_rawsock_sendmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = rawsock_recvmsg,
-+#else
-+ .recvmsg = backport_rawsock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
-@@ -311,7 +331,11 @@ static const struct proto_ops rawsock_raw_ops = {
- .setsockopt = sock_no_setsockopt,
- .getsockopt = sock_no_getsockopt,
- .sendmsg = sock_no_sendmsg,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
- .recvmsg = rawsock_recvmsg,
-+#else
-+ .recvmsg = backport_rawsock_recvmsg,
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
- .mmap = sock_no_mmap,
- };
-
--
2.3.2.209.gd67f9d5.dirty
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [Cocci] [PATCH 4/4] patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
2015-06-06 0:10 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-06 5:33 ` Julia Lawall
-1 siblings, 0 replies; 26+ messages in thread
From: Julia Lawall @ 2015-06-06 5:33 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: backports, cocci
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
for the semantic patch.
julia
On Fri, 5 Jun 2015, Luis R. Rodriguez wrote:
> This replaces the 436 line of unified diff with 152
> lines of grammar Coccinelle SmPL patch. SmPL patch
> equivalence proof tests reveals only cosmetic changes
> between using Coccinelle SmPL and unified diff as shown
> below. The difference shown are the results of two
> trees, one in which we applied the SmPL patch, and another
> in which the old unified patch series were used. This
> gives us an idea of what Coccinelle did differently.
>
> 1 3.0.101 [ OK ]
> 2 3.1.10 [ OK ]
> 3 3.2.68 [ OK ]
> 4 3.3.8 [ OK ]
> 5 3.4.107 [ OK ]
> 6 3.5.7 [ OK ]
> 7 3.6.11 [ OK ]
> 8 3.7.10 [ OK ]
> 9 3.8.13 [ OK ]
> 10 3.9.11 [ OK ]
> 11 3.10.75 [ OK ]
> 12 3.11.10 [ OK ]
> 13 3.12.40 [ OK ]
> 14 3.13.11 [ OK ]
> 15 3.14.39 [ OK ]
> 16 3.15.10 [ OK ]
> 17 3.16.7 [ OK ]
> 18 3.17.8 [ OK ]
> 19 3.18.12 [ OK ]
> 20 3.19.5 [ OK ]
> 21 4.0.0 [ OK ]
> 22 4.1-rc1 [ OK ]
>
> mcgrof@ergon ~/backports (git::master)$ time \
> ./gentree.py --clean --prove-cocci \
> patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci \
> /home/mcgrof/linux-next/ /home/mcgrof/build/backports-20150525
>
> Copy original source files ...
> Applying patches from patches to
> /home/mcgrof/build/backports-20150525 ...
> Proving Coccinelle SmPL patch: 0054-struct-proto_ops-sig.cocci
> Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: ieee802154.patch
> Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: nfc.patch
> Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: bluetooth.patch
>
> Review the difference between what the tree looks like
> by applying your SmPL patch, then reverting that and
> only applying your the patches in the patch series.
>
> Change directory to /home/mcgrof/build/backports-20150525 and run 'git diff'
> diff stat of the changes:
>
> net/bluetooth/hci_sock.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> Done!
>
> real 0m21.965s
> user 0m45.947s
> sys 0m4.072s
>
> Now when I change directory to /home/mcgrof/build/backports-20150525 and
> run 'git diff' I get:
>
> diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
> index 9326bc8..9ca0166 100644
> --- a/net/bluetooth/hci_sock.c
> +++ b/net/bluetooth/hci_sock.c
> @@ -956,7 +956,8 @@ static int hci_sock_recvmsg(struct socket *sock,
> struct msghdr *msg, size_t len,
> #if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket
> *sock,
> struct msghdr *msg, size_t len,
> - int flags){
> + int flags)
> +{
> return hci_sock_recvmsg(sock, msg, len, flags);
> }
> #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> @@ -1198,7 +1199,8 @@ drop:
> }
> #if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket
> *sock,
> - struct msghdr *msg, size_t len){
> + struct msghdr *msg, size_t len)
> +{
> return hci_sock_sendmsg(sock, msg, len);
> }
> #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> @@ -1360,12 +1362,9 @@ static const struct proto_ops hci_sock_ops = {
> .getname = hci_sock_getname,
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> .sendmsg = hci_sock_sendmsg,
> -#else
> - .sendmsg = backport_hci_sock_sendmsg,
> -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> .recvmsg = hci_sock_recvmsg,
> #else
> + .sendmsg = backport_hci_sock_sendmsg,
> .recvmsg = backport_hci_sock_recvmsg,
> #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> .ioctl = hci_sock_ioctl,
>
> Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
> ---
> .../network/0054-struct-proto_ops-sig.cocci | 177 +++++++++++++++++++
> .../0054-struct-proto_ops-sig/bluetooth.patch | 187 ---------------------
> .../0054-struct-proto_ops-sig/ieee802154.patch | 134 ---------------
> .../network/0054-struct-proto_ops-sig/nfc.patch | 115 -------------
> 4 files changed, 177 insertions(+), 436 deletions(-)
> create mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
> delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
> delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
> delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
>
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
> new file mode 100644
> index 0000000..0c0845a
> --- /dev/null
> +++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
> @@ -0,0 +1,177 @@
> +/*
> +This provides the backport for the collateral evolution introduced
> +via commit 1b784140474e4fc94281a49e96c67d29df0efbde, titled
> +"net: Remove iocb argument from sendmsg and recvmsg".
> +
> +The net/tipc/ subsystem (Transparent Inter Process Communication (TIPC))
> +relied historically on using an argument passed on the struct proto_ops
> +and struct proto sendmsg and recvmsg callbacks to determine if it needed
> +to perform a lock within its own code. Commit 1b784140474e4 removed replaced
> +the locking functionality to require the argument and instead moved all
> +the necessary heuristics into net/tipc. Other subsystems just passed NULL.
> +After the net/tipc code was cleaned up from the locking (see commmit
> +39a0295f901423e260a034ac7c3211ecaa9c2745 titled "tipc: Don't use iocb
> +argument in socket layer") we no longer needed the extra argument on the
> +struct proto_ops and struct proto callbacks.
> +
> +To backport non-tipc subsystems we then just need to modify the upstream
> +code which declares these callbacks and add the extra argument again, but
> +the same routine can be used from upstream code. The grammar we use below
> +declares routines which can be pegged to struct proto_ops and struct proto
> +callbacks that simply call the same upstream code, the extra argument is
> +ignored. The argument can be ignored as it was only used within the
> +net/tipc subsystem for locking purposes.
> +*/
> +
> +@ proto_ops @
> +identifier s, send_func, recv_func;
> +@@
> +
> + struct proto_ops s = {
> + .sendmsg = send_func,
> + .recvmsg = recv_func,
> +};
> +
> +@ mod_send depends on proto_ops @
> +identifier proto_ops.send_func;
> +fresh identifier backport_send = "backport_" ## send_func;
> +@@
> +
> +send_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_send(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
> ++{
> ++ return send_func(sock, msg, len);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ mod_recv depends on proto_ops @
> +identifier proto_ops.recv_func;
> +fresh identifier backport_recv = "backport_" ## recv_func;
> +@@
> +
> +recv_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_recv(struct kiocb *iocb, struct socket *sock,
> ++ struct msghdr *msg, size_t len, int flags)
> ++{
> ++ return recv_func(sock, msg, len, flags);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ mod_proto_ops_tx depends on proto_ops && mod_send @
> +identifier s, proto_ops.send_func, mod_send.backport_send;
> +@@
> +
> + struct proto_ops s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .sendmsg = send_func,
> ++#else
> ++ .sendmsg = backport_send,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> +
> +@ mod_proto_ops_rx depends on proto_ops && mod_recv @
> +identifier s, proto_ops.recv_func, mod_recv.backport_recv;
> +@@
> +
> + struct proto_ops s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .recvmsg = recv_func,
> ++#else
> ++ .recvmsg = backport_recv,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> +
> +@ mod_sock_send_callers depends on proto_ops@
> +identifier proto_ops.send_func;
> +identifier sock, msg, len, sk;
> +@@
> +
> +send_func(struct socket *sock, struct msghdr *msg, size_t len)
> +{
> + ...
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + return sk->sk_prot->sendmsg(sk, msg, len);
> ++#else
> ++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +}
> +
> +@ proto @
> +identifier s, send_func, recv_func;
> +@@
> +
> + struct proto s = {
> + .sendmsg = send_func,
> + .recvmsg = recv_func,
> +};
> +
> +@ proto_mod_send depends on proto @
> +identifier proto.send_func;
> +fresh identifier backport_send = "backport_" ## send_func;
> +@@
> +
> +send_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_send(struct kiocb *iocb, struct socket *sock,
> ++ struct msghdr *msg, size_t len)
> ++{
> ++ return send_func(sock, msg, len);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ proto_mod_recv depends on proto @
> +identifier proto.recv_func;
> +fresh identifier backport_recv = "backport_" ## recv_func;
> +@@
> +
> +recv_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_recv(struct kiocb *iocb, struct socket *sock,
> ++ struct msghdr *msg, size_t len,
> ++ int noblock, int flags, int *addr_len)
> ++{
> ++ return recv_func(sock, msg, len, noblock, flags, addr_len);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ mod_proto_tx depends on proto && proto_mod_send @
> +identifier s, proto.send_func, proto_mod_send.backport_send;
> +@@
> +
> + struct proto s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .sendmsg = send_func,
> ++#else
> ++ .sendmsg = backport_send,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> +
> +@ mod_proto_rx depends on proto && proto_mod_recv @
> +identifier s, proto.recv_func, proto_mod_recv.backport_recv;
> +@@
> +
> + struct proto s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .recvmsg = recv_func,
> ++#else
> ++ .recvmsg = backport_recv,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
> deleted file mode 100644
> index 2cf5a9e..0000000
> --- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
> +++ /dev/null
> @@ -1,187 +0,0 @@
> ---- a/net/bluetooth/hci_sock.c
> -+++ b/net/bluetooth/hci_sock.c
> -@@ -953,6 +953,14 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> -
> - return err ? : copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags)
> -+{
> -+ return hci_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
> - struct msghdr *msg, size_t msglen)
> -@@ -1189,6 +1196,13 @@ drop:
> - kfree_skb(skb);
> - goto done;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len)
> -+{
> -+ return hci_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
> - char __user *optval, unsigned int len)
> -@@ -1345,8 +1358,13 @@ static const struct proto_ops hci_sock_ops = {
> - .release = hci_sock_release,
> - .bind = hci_sock_bind,
> - .getname = hci_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = hci_sock_sendmsg,
> - .recvmsg = hci_sock_recvmsg,
> -+#else
> -+ .sendmsg = backport_hci_sock_sendmsg,
> -+ .recvmsg = backport_hci_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .ioctl = hci_sock_ioctl,
> - .poll = datagram_poll,
> - .listen = sock_no_listen,
> ---- a/net/bluetooth/l2cap_sock.c
> -+++ b/net/bluetooth/l2cap_sock.c
> -@@ -975,6 +975,13 @@ static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> -
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_l2cap_sock_sendmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return l2cap_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> - size_t len, int flags)
> -@@ -1036,6 +1043,14 @@ done:
> - release_sock(sk);
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_l2cap_sock_recvmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return l2cap_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - /* Kill socket (only if zapped and orphan)
> - * Must be called on unlocked socket.
> -@@ -1618,8 +1633,16 @@ static const struct proto_ops l2cap_sock_ops = {
> - .listen = l2cap_sock_listen,
> - .accept = l2cap_sock_accept,
> - .getname = l2cap_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = l2cap_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_l2cap_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = l2cap_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_l2cap_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .poll = bt_sock_poll,
> - .ioctl = bt_sock_ioctl,
> - .mmap = sock_no_mmap,
> ---- a/net/bluetooth/rfcomm/sock.c
> -+++ b/net/bluetooth/rfcomm/sock.c
> -@@ -622,6 +622,13 @@ done:
> -
> - return sent;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rfcomm_sock_sendmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return rfcomm_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> - size_t size, int flags)
> -@@ -647,6 +654,14 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> -
> - return len;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rfcomm_sock_recvmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return rfcomm_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
> - {
> -@@ -1044,8 +1059,16 @@ static const struct proto_ops rfcomm_sock_ops = {
> - .listen = rfcomm_sock_listen,
> - .accept = rfcomm_sock_accept,
> - .getname = rfcomm_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = rfcomm_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_rfcomm_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = rfcomm_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_rfcomm_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .shutdown = rfcomm_sock_shutdown,
> - .setsockopt = rfcomm_sock_setsockopt,
> - .getsockopt = rfcomm_sock_getsockopt,
> ---- a/net/bluetooth/sco.c
> -+++ b/net/bluetooth/sco.c
> -@@ -713,6 +713,12 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> - release_sock(sk);
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return sco_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
> - {
> -@@ -779,6 +785,13 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> -
> - return bt_sock_recvmsg(sock, msg, len, flags);
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return sco_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
> - {
> -@@ -1178,8 +1191,16 @@ static const struct proto_ops sco_sock_ops = {
> - .listen = sco_sock_listen,
> - .accept = sco_sock_accept,
> - .getname = sco_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = sco_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_sco_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = sco_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_sco_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .poll = bt_sock_poll,
> - .ioctl = bt_sock_ioctl,
> - .mmap = sock_no_mmap,
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
> deleted file mode 100644
> index 0497dbe..0000000
> --- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
> +++ /dev/null
> @@ -1,134 +0,0 @@
> ---- a/net/ieee802154/socket.c
> -+++ b/net/ieee802154/socket.c
> -@@ -101,8 +101,19 @@ static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> - {
> - struct sock *sk = sock->sk;
> -
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - return sk->sk_prot->sendmsg(sk, msg, len);
> -+#else
> -+ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_ieee802154_sock_sendmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return ieee802154_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
> - int addr_len)
> -@@ -323,6 +334,12 @@ out_dev:
> - out:
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_raw_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return raw_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
> - int noblock, int flags, int *addr_len)
> -@@ -356,6 +373,13 @@ out:
> - return err;
> - return copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_raw_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len, int noblock,
> -+ int flags, int *addr_len){
> -+ return raw_recvmsg(sock, msg, len, noblock, flags, addr_len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
> - {
> -@@ -409,8 +433,16 @@ static struct proto ieee802154_raw_prot = {
> - .obj_size = sizeof(struct sock),
> - .close = raw_close,
> - .bind = raw_bind,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = raw_sendmsg,
> -+#else
> -+ .sendmsg = backport_raw_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = raw_recvmsg,
> -+#else
> -+ .recvmsg = backport_raw_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .hash = raw_hash,
> - .unhash = raw_unhash,
> - .connect = raw_connect,
> -@@ -434,7 +466,11 @@ static const struct proto_ops ieee802154_raw_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = sock_common_setsockopt,
> - .getsockopt = sock_common_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = ieee802154_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_ieee802154_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .recvmsg = sock_common_recvmsg,
> - .mmap = sock_no_mmap,
> - .sendpage = sock_no_sendpage,
> -@@ -710,6 +746,12 @@ out_dev:
> - out:
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_dgram_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return dgram_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
> - int noblock, int flags, int *addr_len)
> -@@ -751,6 +793,13 @@ out:
> - return err;
> - return copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len, int noblock,
> -+ int flags, int *addr_len){
> -+ return dgram_recvmsg(sock, msg, len, noblock, flags, addr_len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
> - {
> -@@ -947,8 +996,16 @@ static struct proto ieee802154_dgram_prot = {
> - .init = dgram_init,
> - .close = dgram_close,
> - .bind = dgram_bind,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = dgram_sendmsg,
> -+#else
> -+ .sendmsg = backport_dgram_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = dgram_recvmsg,
> -+#else
> -+ .recvmsg = backport_dgram_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .hash = dgram_hash,
> - .unhash = dgram_unhash,
> - .connect = dgram_connect,
> -@@ -973,7 +1030,11 @@ static const struct proto_ops ieee802154_dgram_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = sock_common_setsockopt,
> - .getsockopt = sock_common_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = ieee802154_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_ieee802154_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .recvmsg = sock_common_recvmsg,
> - .mmap = sock_no_mmap,
> - .sendpage = sock_no_sendpage,
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
> deleted file mode 100644
> index e29c4d8..0000000
> --- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
> +++ /dev/null
> @@ -1,115 +0,0 @@
> ---- a/net/nfc/llcp_sock.c
> -+++ b/net/nfc/llcp_sock.c
> -@@ -792,6 +792,12 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> -
> - return nfc_llcp_send_i_frame(llcp_sock, msg, len);
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return llcp_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> - size_t len, int flags)
> -@@ -882,6 +888,13 @@ done:
> -
> - return copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return llcp_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static const struct proto_ops llcp_sock_ops = {
> - .family = PF_NFC,
> -@@ -898,8 +911,16 @@ static const struct proto_ops llcp_sock_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = nfc_llcp_setsockopt,
> - .getsockopt = nfc_llcp_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = llcp_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_llcp_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = llcp_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_llcp_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> -@@ -919,7 +940,11 @@ static const struct proto_ops llcp_rawsock_ops = {
> - .setsockopt = sock_no_setsockopt,
> - .getsockopt = sock_no_getsockopt,
> - .sendmsg = sock_no_sendmsg,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = llcp_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_llcp_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> ---- a/net/nfc/rawsock.c
> -+++ b/net/nfc/rawsock.c
> -@@ -246,6 +246,12 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
> -
> - return len;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return rawsock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> - int flags)
> -@@ -274,6 +280,12 @@ static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> -
> - return rc ? : copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len, int flags){
> -+ return rawsock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static const struct proto_ops rawsock_ops = {
> - .family = PF_NFC,
> -@@ -290,8 +302,16 @@ static const struct proto_ops rawsock_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = sock_no_setsockopt,
> - .getsockopt = sock_no_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = rawsock_sendmsg,
> -+#else
> -+ .sendmsg = backport_rawsock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = rawsock_recvmsg,
> -+#else
> -+ .recvmsg = backport_rawsock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> -@@ -311,7 +331,11 @@ static const struct proto_ops rawsock_raw_ops = {
> - .setsockopt = sock_no_setsockopt,
> - .getsockopt = sock_no_getsockopt,
> - .sendmsg = sock_no_sendmsg,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = rawsock_recvmsg,
> -+#else
> -+ .recvmsg = backport_rawsock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> --
> 2.3.2.209.gd67f9d5.dirty
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 26+ messages in thread* [Cocci] [PATCH 4/4] patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
@ 2015-06-06 5:33 ` Julia Lawall
0 siblings, 0 replies; 26+ messages in thread
From: Julia Lawall @ 2015-06-06 5:33 UTC (permalink / raw)
To: cocci
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
for the semantic patch.
julia
On Fri, 5 Jun 2015, Luis R. Rodriguez wrote:
> This replaces the 436 line of unified diff with 152
> lines of grammar Coccinelle SmPL patch. SmPL patch
> equivalence proof tests reveals only cosmetic changes
> between using Coccinelle SmPL and unified diff as shown
> below. The difference shown are the results of two
> trees, one in which we applied the SmPL patch, and another
> in which the old unified patch series were used. This
> gives us an idea of what Coccinelle did differently.
>
> 1 3.0.101 [ OK ]
> 2 3.1.10 [ OK ]
> 3 3.2.68 [ OK ]
> 4 3.3.8 [ OK ]
> 5 3.4.107 [ OK ]
> 6 3.5.7 [ OK ]
> 7 3.6.11 [ OK ]
> 8 3.7.10 [ OK ]
> 9 3.8.13 [ OK ]
> 10 3.9.11 [ OK ]
> 11 3.10.75 [ OK ]
> 12 3.11.10 [ OK ]
> 13 3.12.40 [ OK ]
> 14 3.13.11 [ OK ]
> 15 3.14.39 [ OK ]
> 16 3.15.10 [ OK ]
> 17 3.16.7 [ OK ]
> 18 3.17.8 [ OK ]
> 19 3.18.12 [ OK ]
> 20 3.19.5 [ OK ]
> 21 4.0.0 [ OK ]
> 22 4.1-rc1 [ OK ]
>
> mcgrof at ergon ~/backports (git::master)$ time \
> ./gentree.py --clean --prove-cocci \
> patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci \
> /home/mcgrof/linux-next/ /home/mcgrof/build/backports-20150525
>
> Copy original source files ...
> Applying patches from patches to
> /home/mcgrof/build/backports-20150525 ...
> Proving Coccinelle SmPL patch: 0054-struct-proto_ops-sig.cocci
> Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: ieee802154.patch
> Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: nfc.patch
> Aggregating patch for Coccinelle SmPL 0054-struct-proto_ops-sig proof: bluetooth.patch
>
> Review the difference between what the tree looks like
> by applying your SmPL patch, then reverting that and
> only applying your the patches in the patch series.
>
> Change directory to /home/mcgrof/build/backports-20150525 and run 'git diff'
> diff stat of the changes:
>
> net/bluetooth/hci_sock.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> Done!
>
> real 0m21.965s
> user 0m45.947s
> sys 0m4.072s
>
> Now when I change directory to /home/mcgrof/build/backports-20150525 and
> run 'git diff' I get:
>
> diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
> index 9326bc8..9ca0166 100644
> --- a/net/bluetooth/hci_sock.c
> +++ b/net/bluetooth/hci_sock.c
> @@ -956,7 +956,8 @@ static int hci_sock_recvmsg(struct socket *sock,
> struct msghdr *msg, size_t len,
> #if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket
> *sock,
> struct msghdr *msg, size_t len,
> - int flags){
> + int flags)
> +{
> return hci_sock_recvmsg(sock, msg, len, flags);
> }
> #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> @@ -1198,7 +1199,8 @@ drop:
> }
> #if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket
> *sock,
> - struct msghdr *msg, size_t len){
> + struct msghdr *msg, size_t len)
> +{
> return hci_sock_sendmsg(sock, msg, len);
> }
> #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> @@ -1360,12 +1362,9 @@ static const struct proto_ops hci_sock_ops = {
> .getname = hci_sock_getname,
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> .sendmsg = hci_sock_sendmsg,
> -#else
> - .sendmsg = backport_hci_sock_sendmsg,
> -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> .recvmsg = hci_sock_recvmsg,
> #else
> + .sendmsg = backport_hci_sock_sendmsg,
> .recvmsg = backport_hci_sock_recvmsg,
> #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> .ioctl = hci_sock_ioctl,
>
> Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
> ---
> .../network/0054-struct-proto_ops-sig.cocci | 177 +++++++++++++++++++
> .../0054-struct-proto_ops-sig/bluetooth.patch | 187 ---------------------
> .../0054-struct-proto_ops-sig/ieee802154.patch | 134 ---------------
> .../network/0054-struct-proto_ops-sig/nfc.patch | 115 -------------
> 4 files changed, 177 insertions(+), 436 deletions(-)
> create mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
> delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
> delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
> delete mode 100644 patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
>
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
> new file mode 100644
> index 0000000..0c0845a
> --- /dev/null
> +++ b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig.cocci
> @@ -0,0 +1,177 @@
> +/*
> +This provides the backport for the collateral evolution introduced
> +via commit 1b784140474e4fc94281a49e96c67d29df0efbde, titled
> +"net: Remove iocb argument from sendmsg and recvmsg".
> +
> +The net/tipc/ subsystem (Transparent Inter Process Communication (TIPC))
> +relied historically on using an argument passed on the struct proto_ops
> +and struct proto sendmsg and recvmsg callbacks to determine if it needed
> +to perform a lock within its own code. Commit 1b784140474e4 removed replaced
> +the locking functionality to require the argument and instead moved all
> +the necessary heuristics into net/tipc. Other subsystems just passed NULL.
> +After the net/tipc code was cleaned up from the locking (see commmit
> +39a0295f901423e260a034ac7c3211ecaa9c2745 titled "tipc: Don't use iocb
> +argument in socket layer") we no longer needed the extra argument on the
> +struct proto_ops and struct proto callbacks.
> +
> +To backport non-tipc subsystems we then just need to modify the upstream
> +code which declares these callbacks and add the extra argument again, but
> +the same routine can be used from upstream code. The grammar we use below
> +declares routines which can be pegged to struct proto_ops and struct proto
> +callbacks that simply call the same upstream code, the extra argument is
> +ignored. The argument can be ignored as it was only used within the
> +net/tipc subsystem for locking purposes.
> +*/
> +
> +@ proto_ops @
> +identifier s, send_func, recv_func;
> +@@
> +
> + struct proto_ops s = {
> + .sendmsg = send_func,
> + .recvmsg = recv_func,
> +};
> +
> +@ mod_send depends on proto_ops @
> +identifier proto_ops.send_func;
> +fresh identifier backport_send = "backport_" ## send_func;
> +@@
> +
> +send_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_send(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
> ++{
> ++ return send_func(sock, msg, len);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ mod_recv depends on proto_ops @
> +identifier proto_ops.recv_func;
> +fresh identifier backport_recv = "backport_" ## recv_func;
> +@@
> +
> +recv_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_recv(struct kiocb *iocb, struct socket *sock,
> ++ struct msghdr *msg, size_t len, int flags)
> ++{
> ++ return recv_func(sock, msg, len, flags);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ mod_proto_ops_tx depends on proto_ops && mod_send @
> +identifier s, proto_ops.send_func, mod_send.backport_send;
> +@@
> +
> + struct proto_ops s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .sendmsg = send_func,
> ++#else
> ++ .sendmsg = backport_send,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> +
> +@ mod_proto_ops_rx depends on proto_ops && mod_recv @
> +identifier s, proto_ops.recv_func, mod_recv.backport_recv;
> +@@
> +
> + struct proto_ops s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .recvmsg = recv_func,
> ++#else
> ++ .recvmsg = backport_recv,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> +
> +@ mod_sock_send_callers depends on proto_ops@
> +identifier proto_ops.send_func;
> +identifier sock, msg, len, sk;
> +@@
> +
> +send_func(struct socket *sock, struct msghdr *msg, size_t len)
> +{
> + ...
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + return sk->sk_prot->sendmsg(sk, msg, len);
> ++#else
> ++ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +}
> +
> +@ proto @
> +identifier s, send_func, recv_func;
> +@@
> +
> + struct proto s = {
> + .sendmsg = send_func,
> + .recvmsg = recv_func,
> +};
> +
> +@ proto_mod_send depends on proto @
> +identifier proto.send_func;
> +fresh identifier backport_send = "backport_" ## send_func;
> +@@
> +
> +send_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_send(struct kiocb *iocb, struct socket *sock,
> ++ struct msghdr *msg, size_t len)
> ++{
> ++ return send_func(sock, msg, len);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ proto_mod_recv depends on proto @
> +identifier proto.recv_func;
> +fresh identifier backport_recv = "backport_" ## recv_func;
> +@@
> +
> +recv_func(...)
> +{
> + ...
> +}
> +
> ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> ++static int backport_recv(struct kiocb *iocb, struct socket *sock,
> ++ struct msghdr *msg, size_t len,
> ++ int noblock, int flags, int *addr_len)
> ++{
> ++ return recv_func(sock, msg, len, noblock, flags, addr_len);
> ++}
> ++#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> +
> +@ mod_proto_tx depends on proto && proto_mod_send @
> +identifier s, proto.send_func, proto_mod_send.backport_send;
> +@@
> +
> + struct proto s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .sendmsg = send_func,
> ++#else
> ++ .sendmsg = backport_send,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> +
> +@ mod_proto_rx depends on proto && proto_mod_recv @
> +identifier s, proto.recv_func, proto_mod_recv.backport_recv;
> +@@
> +
> + struct proto s = {
> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> + .recvmsg = recv_func,
> ++#else
> ++ .recvmsg = backport_recv,
> ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> +};
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
> deleted file mode 100644
> index 2cf5a9e..0000000
> --- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/bluetooth.patch
> +++ /dev/null
> @@ -1,187 +0,0 @@
> ---- a/net/bluetooth/hci_sock.c
> -+++ b/net/bluetooth/hci_sock.c
> -@@ -953,6 +953,14 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> -
> - return err ? : copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags)
> -+{
> -+ return hci_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
> - struct msghdr *msg, size_t msglen)
> -@@ -1189,6 +1196,13 @@ drop:
> - kfree_skb(skb);
> - goto done;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len)
> -+{
> -+ return hci_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
> - char __user *optval, unsigned int len)
> -@@ -1345,8 +1358,13 @@ static const struct proto_ops hci_sock_ops = {
> - .release = hci_sock_release,
> - .bind = hci_sock_bind,
> - .getname = hci_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = hci_sock_sendmsg,
> - .recvmsg = hci_sock_recvmsg,
> -+#else
> -+ .sendmsg = backport_hci_sock_sendmsg,
> -+ .recvmsg = backport_hci_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .ioctl = hci_sock_ioctl,
> - .poll = datagram_poll,
> - .listen = sock_no_listen,
> ---- a/net/bluetooth/l2cap_sock.c
> -+++ b/net/bluetooth/l2cap_sock.c
> -@@ -975,6 +975,13 @@ static int l2cap_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> -
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_l2cap_sock_sendmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return l2cap_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> - size_t len, int flags)
> -@@ -1036,6 +1043,14 @@ done:
> - release_sock(sk);
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_l2cap_sock_recvmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return l2cap_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - /* Kill socket (only if zapped and orphan)
> - * Must be called on unlocked socket.
> -@@ -1618,8 +1633,16 @@ static const struct proto_ops l2cap_sock_ops = {
> - .listen = l2cap_sock_listen,
> - .accept = l2cap_sock_accept,
> - .getname = l2cap_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = l2cap_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_l2cap_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = l2cap_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_l2cap_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .poll = bt_sock_poll,
> - .ioctl = bt_sock_ioctl,
> - .mmap = sock_no_mmap,
> ---- a/net/bluetooth/rfcomm/sock.c
> -+++ b/net/bluetooth/rfcomm/sock.c
> -@@ -622,6 +622,13 @@ done:
> -
> - return sent;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rfcomm_sock_sendmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return rfcomm_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> - size_t size, int flags)
> -@@ -647,6 +654,14 @@ static int rfcomm_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> -
> - return len;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rfcomm_sock_recvmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return rfcomm_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
> - {
> -@@ -1044,8 +1059,16 @@ static const struct proto_ops rfcomm_sock_ops = {
> - .listen = rfcomm_sock_listen,
> - .accept = rfcomm_sock_accept,
> - .getname = rfcomm_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = rfcomm_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_rfcomm_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = rfcomm_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_rfcomm_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .shutdown = rfcomm_sock_shutdown,
> - .setsockopt = rfcomm_sock_setsockopt,
> - .getsockopt = rfcomm_sock_getsockopt,
> ---- a/net/bluetooth/sco.c
> -+++ b/net/bluetooth/sco.c
> -@@ -713,6 +713,12 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> - release_sock(sk);
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return sco_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
> - {
> -@@ -779,6 +785,13 @@ static int sco_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> -
> - return bt_sock_recvmsg(sock, msg, len, flags);
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return sco_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
> - {
> -@@ -1178,8 +1191,16 @@ static const struct proto_ops sco_sock_ops = {
> - .listen = sco_sock_listen,
> - .accept = sco_sock_accept,
> - .getname = sco_sock_getname,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = sco_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_sco_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = sco_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_sco_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .poll = bt_sock_poll,
> - .ioctl = bt_sock_ioctl,
> - .mmap = sock_no_mmap,
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
> deleted file mode 100644
> index 0497dbe..0000000
> --- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/ieee802154.patch
> +++ /dev/null
> @@ -1,134 +0,0 @@
> ---- a/net/ieee802154/socket.c
> -+++ b/net/ieee802154/socket.c
> -@@ -101,8 +101,19 @@ static int ieee802154_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> - {
> - struct sock *sk = sock->sk;
> -
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - return sk->sk_prot->sendmsg(sk, msg, len);
> -+#else
> -+ return sk->sk_prot->sendmsg(NULL, sk, msg, len);
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_ieee802154_sock_sendmsg(struct kiocb *iocb,
> -+ struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return ieee802154_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
> - int addr_len)
> -@@ -323,6 +334,12 @@ out_dev:
> - out:
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_raw_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return raw_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int raw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
> - int noblock, int flags, int *addr_len)
> -@@ -356,6 +373,13 @@ out:
> - return err;
> - return copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_raw_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len, int noblock,
> -+ int flags, int *addr_len){
> -+ return raw_recvmsg(sock, msg, len, noblock, flags, addr_len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
> - {
> -@@ -409,8 +433,16 @@ static struct proto ieee802154_raw_prot = {
> - .obj_size = sizeof(struct sock),
> - .close = raw_close,
> - .bind = raw_bind,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = raw_sendmsg,
> -+#else
> -+ .sendmsg = backport_raw_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = raw_recvmsg,
> -+#else
> -+ .recvmsg = backport_raw_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .hash = raw_hash,
> - .unhash = raw_unhash,
> - .connect = raw_connect,
> -@@ -434,7 +466,11 @@ static const struct proto_ops ieee802154_raw_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = sock_common_setsockopt,
> - .getsockopt = sock_common_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = ieee802154_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_ieee802154_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .recvmsg = sock_common_recvmsg,
> - .mmap = sock_no_mmap,
> - .sendpage = sock_no_sendpage,
> -@@ -710,6 +746,12 @@ out_dev:
> - out:
> - return err;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_dgram_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return dgram_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
> - int noblock, int flags, int *addr_len)
> -@@ -751,6 +793,13 @@ out:
> - return err;
> - return copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len, int noblock,
> -+ int flags, int *addr_len){
> -+ return dgram_recvmsg(sock, msg, len, noblock, flags, addr_len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int dgram_rcv_skb(struct sock *sk, struct sk_buff *skb)
> - {
> -@@ -947,8 +996,16 @@ static struct proto ieee802154_dgram_prot = {
> - .init = dgram_init,
> - .close = dgram_close,
> - .bind = dgram_bind,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = dgram_sendmsg,
> -+#else
> -+ .sendmsg = backport_dgram_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = dgram_recvmsg,
> -+#else
> -+ .recvmsg = backport_dgram_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .hash = dgram_hash,
> - .unhash = dgram_unhash,
> - .connect = dgram_connect,
> -@@ -973,7 +1030,11 @@ static const struct proto_ops ieee802154_dgram_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = sock_common_setsockopt,
> - .getsockopt = sock_common_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = ieee802154_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_ieee802154_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .recvmsg = sock_common_recvmsg,
> - .mmap = sock_no_mmap,
> - .sendpage = sock_no_sendpage,
> diff --git a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch b/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
> deleted file mode 100644
> index e29c4d8..0000000
> --- a/patches/collateral-evolutions/network/0054-struct-proto_ops-sig/nfc.patch
> +++ /dev/null
> @@ -1,115 +0,0 @@
> ---- a/net/nfc/llcp_sock.c
> -+++ b/net/nfc/llcp_sock.c
> -@@ -792,6 +792,12 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
> -
> - return nfc_llcp_send_i_frame(llcp_sock, msg, len);
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return llcp_sock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int llcp_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> - size_t len, int flags)
> -@@ -882,6 +888,13 @@ done:
> -
> - return copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len,
> -+ int flags){
> -+ return llcp_sock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static const struct proto_ops llcp_sock_ops = {
> - .family = PF_NFC,
> -@@ -898,8 +911,16 @@ static const struct proto_ops llcp_sock_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = nfc_llcp_setsockopt,
> - .getsockopt = nfc_llcp_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = llcp_sock_sendmsg,
> -+#else
> -+ .sendmsg = backport_llcp_sock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = llcp_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_llcp_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> -@@ -919,7 +940,11 @@ static const struct proto_ops llcp_rawsock_ops = {
> - .setsockopt = sock_no_setsockopt,
> - .getsockopt = sock_no_getsockopt,
> - .sendmsg = sock_no_sendmsg,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = llcp_sock_recvmsg,
> -+#else
> -+ .recvmsg = backport_llcp_sock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> ---- a/net/nfc/rawsock.c
> -+++ b/net/nfc/rawsock.c
> -@@ -246,6 +246,12 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
> -
> - return len;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len){
> -+ return rawsock_sendmsg(sock, msg, len);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> - int flags)
> -@@ -274,6 +280,12 @@ static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> -
> - return rc ? : copied;
> - }
> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
> -+static int backport_rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
> -+ struct msghdr *msg, size_t len, int flags){
> -+ return rawsock_recvmsg(sock, msg, len, flags);
> -+}
> -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */
> -
> - static const struct proto_ops rawsock_ops = {
> - .family = PF_NFC,
> -@@ -290,8 +302,16 @@ static const struct proto_ops rawsock_ops = {
> - .shutdown = sock_no_shutdown,
> - .setsockopt = sock_no_setsockopt,
> - .getsockopt = sock_no_getsockopt,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .sendmsg = rawsock_sendmsg,
> -+#else
> -+ .sendmsg = backport_rawsock_sendmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = rawsock_recvmsg,
> -+#else
> -+ .recvmsg = backport_rawsock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> -@@ -311,7 +331,11 @@ static const struct proto_ops rawsock_raw_ops = {
> - .setsockopt = sock_no_setsockopt,
> - .getsockopt = sock_no_getsockopt,
> - .sendmsg = sock_no_sendmsg,
> -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
> - .recvmsg = rawsock_recvmsg,
> -+#else
> -+ .recvmsg = backport_rawsock_recvmsg,
> -+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */
> - .mmap = sock_no_mmap,
> - };
> -
> --
> 2.3.2.209.gd67f9d5.dirty
>
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Cocci] [PATCH 4/4] patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
2015-06-06 5:33 ` Julia Lawall
@ 2015-06-08 21:00 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-08 21:00 UTC (permalink / raw)
To: Julia Lawall; +Cc: Luis R. Rodriguez, backports, cocci
On Sat, Jun 06, 2015 at 07:33:21AM +0200, Julia Lawall wrote:
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Thanks for the review, I'll drop the SmPL proof support patches
but merge the rest.
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 0/4] backports: SmPL patch equivalence support
2015-06-06 0:09 ` [Cocci] " Luis R. Rodriguez
@ 2015-06-09 22:18 ` Luis R. Rodriguez
-1 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-09 22:18 UTC (permalink / raw)
To: backports@vger.kernel.org; +Cc: cocci@systeme.lip6.fr, Luis R. Rodriguez
On Fri, Jun 5, 2015 at 5:09 PM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
> Luis R. Rodriguez (4):
> patches: remove bt_sock_stream_recvmsg() and bt_sock_recvmsg() from
> ifdefs
> patches: change 0054-struct-proto_ops-sig backport strategy
> gentree.py: add SmPL patch equivalence proof support
> patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
FYI - dropped the gentree.py patch for SmPL proof support and pushed the rest.
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Cocci] [PATCH 0/4] backports: SmPL patch equivalence support
@ 2015-06-09 22:18 ` Luis R. Rodriguez
0 siblings, 0 replies; 26+ messages in thread
From: Luis R. Rodriguez @ 2015-06-09 22:18 UTC (permalink / raw)
To: cocci
On Fri, Jun 5, 2015 at 5:09 PM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
> Luis R. Rodriguez (4):
> patches: remove bt_sock_stream_recvmsg() and bt_sock_recvmsg() from
> ifdefs
> patches: change 0054-struct-proto_ops-sig backport strategy
> gentree.py: add SmPL patch equivalence proof support
> patches: provide 0054-struct-proto_ops-sig SmPL patch replacement
FYI - dropped the gentree.py patch for SmPL proof support and pushed the rest.
Luis
^ permalink raw reply [flat|nested] 26+ messages in thread