mirror of
https://github.com/openharmony/kernel_linux_common_modules.git
synced 2026-08-27 01:31:36 -04:00
ninet_ioctl add the SIOCGIFCONF
Signed-off-by: liangbotong <liangbotong@huawei.com>
This commit is contained in:
@@ -15,9 +15,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/hck/lite_hck_inet.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/ninet_hashtables.h> /* ninet_ehashfn */
|
||||
#include <net/if_ninet.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, <obz@Kodak.COM>
|
||||
* Ross Biro
|
||||
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
|
||||
*
|
||||
* 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 <linux/stat.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/sched/signal.h> /* for signal_pending() */
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include <net/nip.h>
|
||||
#include <net/udp.h>
|
||||
@@ -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);
|
||||
|
||||
+35
-1
@@ -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, <waltje@uWalt.NL.Mugnet.ORG>
|
||||
* Mark Evans, <evansmp@uhura.aston.ac.uk>
|
||||
*
|
||||
@@ -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 <linux/netdevice.h>
|
||||
|
||||
#include <net/nip_fib.h>
|
||||
#include <net/nip_addrconf.h>
|
||||
#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);
|
||||
|
||||
+4
-4
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user