diff --git a/newip/src/linux-5.10/net/newip/nip_hooks_register.c b/newip/src/linux-5.10/net/newip/nip_hooks_register.c index 556d573c57634f4efb89eac1ee9e827006c0127c..267bdb119ad9b564f613f3c9bb74268052ac1185 100644 --- a/newip/src/linux-5.10/net/newip/nip_hooks_register.c +++ b/newip/src/linux-5.10/net/newip/nip_hooks_register.c @@ -15,9 +15,7 @@ #include #include #include -#include #include /* ninet_ehashfn */ -#include #include "tcp_nip_parameter.h" /* call the newip hook function in sk_ehashfn function (net\ipv4\inet_hashtables.c): @@ -31,35 +29,14 @@ void nip_ninet_ehashfn(const struct sock *sk, u32 *ret) sk->sk_num, &sk->SK_NIP_DADDR, sk->sk_dport); } -/* call the newip hook function in inet_gifconf function (net\ipv4\devinet.c): - */ -void nip_ninet_gifconf(struct net_device *dev, - char __user *buf, int len, int size, int *v4_done) -{ - if (*v4_done >= 0) { - int done = ninet_gifconf(dev, (buf) ? buf + *v4_done : buf, len, size); - - if (done < 0) - *v4_done = done; - else - *v4_done += done; - } -} - void nip_ninet_ehashfn_lhck_register(void) { REGISTER_HCK_LITE_HOOK(nip_ninet_ehashfn_lhck, nip_ninet_ehashfn); } -void nip_ninet_gifconf_lhck_register(void) -{ - REGISTER_HCK_LITE_HOOK(nip_ninet_gifconf_lhck, nip_ninet_gifconf); -} - int __init ninet_hooks_init(void) { nip_ninet_ehashfn_lhck_register(); - nip_ninet_gifconf_lhck_register(); return 0; } diff --git a/newip/third_party/linux-5.10/include/net/if_ninet.h b/newip/third_party/linux-5.10/include/net/if_ninet.h index 21c44988dc733b1268d9be98749f9b04423bebb7..3f9b8f9ddc952bbd9abf1b94ca6b8db93fc29aaf 100644 --- a/newip/third_party/linux-5.10/include/net/if_ninet.h +++ b/newip/third_party/linux-5.10/include/net/if_ninet.h @@ -64,6 +64,7 @@ struct ninet_dev { }; int ninet_gifconf(struct net_device *dev, char __user *buf, int len, int size); +int nip_dev_ifconf(struct net *net, struct ifconf *ifc, int size); int ninet_ioctl_cmd(struct socket *sock, const struct iovec *iov); #endif diff --git a/newip/third_party/linux-5.10/net/newip/af_ninet.c b/newip/third_party/linux-5.10/net/newip/af_ninet.c index 1620c8cb32bc31bfd83f1cea8bf9a8621de5bf59..f1ce6a9c9768406b1c71cef3cf89c577441afb17 100644 --- a/newip/third_party/linux-5.10/net/newip/af_ninet.c +++ b/newip/third_party/linux-5.10/net/newip/af_ninet.c @@ -9,6 +9,49 @@ * Hideaki YOSHIFUJI : sin6_scope_id support * Arnaldo Melo : check proc_net_create return, cleanups * + * Based on linux/net/socket.c + * Authors: Orest Zborowski, + * Ross Biro + * Fred N. van Kempen, + * + * Fixes: + * Anonymous : NOTSOCK/BADF cleanup. Error fix in + * shutdown() + * Alan Cox : verify_area() fixes + * Alan Cox : Removed DDI + * Jonathan Kamens : SOCK_DGRAM reconnect bug + * Alan Cox : Moved a load of checks to the very + * top level. + * Alan Cox : Move address structures to/from user + * mode above the protocol layers. + * Rob Janssen : Allow 0 length sends. + * Alan Cox : Asynchronous I/O support (cribbed from the + * tty drivers). + * Niibe Yutaka : Asynchronous I/O for writes (4.4BSD style) + * Jeff Uphoff : Made max number of sockets command-line + * configurable. + * Matti Aarnio : Made the number of sockets dynamic, + * to be allocated when needed, and mr. + * Uphoff's max is used as max to be + * allowed to allocate. + * Linus : Argh. removed all the socket allocation + * altogether: it's in the inode now. + * Alan Cox : Made sock_alloc()/sock_release() public + * for NetROM and future kernel nfsd type + * stuff. + * Alan Cox : sendmsg/recvmsg basics. + * Tom Dyas : Export net symbols. + * Marcin Dalecki : Fixed problems with CONFIG_NET="n". + * Alan Cox : Added thread locking to sys_* calls + * for sockets. May have errors at the + * moment. + * Kevin Buhr : Fixed the dumb errors in the above. + * Andi Kleen : Some small cleanups, optimizations, + * and fixed a copy_from_user() bug. + * Tigran Aivazian : sys_send(args) calls sys_sendto(args, NULL, 0) + * Tigran Aivazian : Made listen(2) backlog sanity checks + * protocol-independent + * * NewIP INET socket protocol family * Linux NewIP INET implementation */ @@ -28,6 +71,9 @@ #include #include #include /* for signal_pending() */ +#include +#include +#include #include #include @@ -459,7 +505,19 @@ int ninet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return nip_addrconf_del_ifaddr(net, (void __user *)arg); case SIOCGIFADDR: return nip_addrconf_get_ifaddr(net, cmd, (void __user *)arg); + case SIOCGIFCONF: { + struct ifconf ifc; + int err; + if (copy_from_user(&ifc, (void __user *)arg, sizeof(struct ifconf))) + return -EFAULT; + rtnl_lock(); + err = nip_dev_ifconf(net, &ifc, sizeof(struct ifreq)); + rtnl_unlock(); + if (!err && copy_to_user((void __user *)arg, &ifc, sizeof(struct ifconf))) + err = -EFAULT; + return err; + } default: if (!sk->sk_prot->ioctl) { nip_dbg("sock sk_prot ioctl is null, cmd=0x%x", cmd); diff --git a/newip/third_party/linux-5.10/net/newip/devninet.c b/newip/third_party/linux-5.10/net/newip/devninet.c index 66428e1b1a8260969c59b97b701242a43a8f4bb8..ac24ec8d928081e3f80503922b0d316696fb477b 100644 --- a/newip/third_party/linux-5.10/net/newip/devninet.c +++ b/newip/third_party/linux-5.10/net/newip/devninet.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* * Based on net/ipv4/devinet.c - * Authors: Ross Biro + * Authors: Ross Biro * Fred N. van Kempen, * Mark Evans, * @@ -18,6 +18,9 @@ * fall back to comparing just the label * if no match found. * + * Based on net/core/dev_ioctl.c + * No Authors, no Copyright + * * NewIP INET * An implementation of the TCP/IP protocol suite for the LINUX * operating system. NewIP INET is implemented using the BSD Socket @@ -27,10 +30,41 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": [%s:%d] " fmt, __func__, __LINE__ +#include + #include #include #include "tcp_nip_parameter.h" +int nip_dev_ifconf(struct net *net, struct ifconf *ifc, int size) +{ + struct net_device *dev; + char __user *pos; + int len; + int total; + + pos = ifc->ifc_buf; + len = ifc->ifc_len; + + total = 0; + for_each_netdev(net, dev) { + int done; + + if (!pos) + done = ninet_gifconf(dev, NULL, 0, size); + else + done = ninet_gifconf(dev, pos + total, + len - total, size); + if (done < 0) + return -EFAULT; + total += done; + } + + ifc->ifc_len = total; + + return 0; +} + int ninet_gifconf(struct net_device *dev, char __user *buf, int len, int size) { struct ninet_dev *nin_dev = __nin_dev_get(dev); diff --git a/newip/third_party/linux-5.10/net/newip/tcp_nip.c b/newip/third_party/linux-5.10/net/newip/tcp_nip.c index 4d345b8b0709e552913382cd4db8c3b99a37c793..39a2c7ff19ac1a358b5d1bf6811a99b270eeaaf6 100644 --- a/newip/third_party/linux-5.10/net/newip/tcp_nip.c +++ b/newip/third_party/linux-5.10/net/newip/tcp_nip.c @@ -985,7 +985,7 @@ put_and_exit: goto out; } -static void tcp_nip__send_check(struct sock *sk, struct sk_buff *skb) +static void tcp_nip_send_check(struct sock *sk, struct sk_buff *skb) { } @@ -1004,7 +1004,7 @@ static void nip_mtu_reduced(struct sock *sk) static const struct inet_connection_sock_af_ops newip_specific = { .queue_xmit = tcp_nip_queue_xmit, - .send_check = tcp_nip__send_check, + .send_check = tcp_nip_send_check, .rebuild_header = tcp_nip_rebuild_header, .sk_rx_dst_set = ninet_sk_rx_dst_set, .conn_request = tcp_nip_conn_request, @@ -1328,8 +1328,8 @@ static void inet_connection_sock_pre_init(struct inet_connection_sock *icsk) } #ifdef CONFIG_TCP_MD5SIG -struct tcp_md5sig_key *nip_md5_lookup(const struct sock *sk, - const struct sock *addr_sk) +struct tcp_md5sig_key *nip_md5_lookup(const struct sock *sk, + const struct sock *addr_sk) { return NULL; }