mirror of
https://github.com/openharmony/kernel_common_modules_newip.git
synced 2026-07-19 16:43:31 -04:00
清除 newip 内核打印信息时用的英文句号
nip_dbg替换DEBUG,log中./!等结束符删除,超长变量名整改 SSTHRESH_DBG 修改成 ssthresh_dbg,RETRANS_DBG 修改成 retrans_dbg 解决删除路由后再增加后socket恢复问题 用户态获取配置newip地址的接口列表,新增api接口(SIOCGIFCONF) Signed-off-by: yangyanjun <yangyanjun@huawei.com>
This commit is contained in:
@@ -273,10 +273,11 @@ int nip_hdr_parse(unsigned char *rcv_buf, unsigned int buf_len, struct nip_hdr_d
|
||||
|
||||
niph->rcv_buf_len = buf_len;
|
||||
while (i < num) {
|
||||
int len;
|
||||
|
||||
if (i >= FACTORY_NUM_MAX)
|
||||
break;
|
||||
int len = hdr_parse_factory[i](buf, bitmap[i], niph);
|
||||
|
||||
len = hdr_parse_factory[i](buf, bitmap[i], niph);
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
|
||||
@@ -61,4 +61,6 @@ struct ninet_dev {
|
||||
struct rcu_head rcu;
|
||||
};
|
||||
|
||||
int ninet_gifconf(struct net_device *dev, char __user *buf, int len, int size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -127,6 +127,5 @@ int nip_getsockopt(struct sock *sk, int level,
|
||||
int nip_addrconf_get_ifaddr(struct net *net, unsigned int cmd, void __user *arg);
|
||||
|
||||
void nip_dbg(const char *fmt, ...);
|
||||
#define DEBUG(format, ...) nip_dbg(format, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -117,11 +117,11 @@ static inline void tcp_nip_check_probe_timer(struct sock *sk)
|
||||
|
||||
if (!tcp_sk(sk)->packets_out && !inet_csk(sk)->icsk_pending) {
|
||||
when = tcp_probe0_base(sk);
|
||||
DEBUG("%s start probe0 timer, when=%u, RTO MAX=%u", __func__, when, TCP_RTO_MAX);
|
||||
nip_dbg("%s start probe0 timer, when=%u, RTO MAX=%u", __func__, when, TCP_RTO_MAX);
|
||||
inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, TCP_RTO_MAX);
|
||||
} else if (inet_csk(sk)->icsk_pending != ICSK_TIME_PROBE0) {
|
||||
DEBUG("%s can`t start probe0 timer, packets_out=%u, icsk_pending=%u",
|
||||
__func__, tcp_sk(sk)->packets_out, inet_csk(sk)->icsk_pending);
|
||||
nip_dbg("%s can`t start probe0 timer, packets_out=%u, icsk_pending=%u",
|
||||
__func__, tcp_sk(sk)->packets_out, inet_csk(sk)->icsk_pending);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
#ifdef CONFIG_NEWIP_HOOKS
|
||||
|
||||
/* include/trace/hooks/nip_hooks.h */
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM nip_hooks /* Header file name */
|
||||
#define TRACE_INCLUDE_PATH trace/hooks /* Header file directory */
|
||||
@@ -20,13 +19,20 @@
|
||||
struct net;
|
||||
struct nip_addr;
|
||||
DECLARE_HOOK(ninet_ehashfn_hook,
|
||||
TP_PROTO(const struct net *net, const struct nip_addr *laddr, const u16 lport,
|
||||
const struct nip_addr *faddr, const __be16 fport, u32 *ret),
|
||||
TP_ARGS(net, laddr, lport, faddr, fport, ret)
|
||||
TP_PROTO(const struct net *net, const struct nip_addr *laddr, const u16 lport,
|
||||
const struct nip_addr *faddr, const __be16 fport, u32 *ret),
|
||||
TP_ARGS(net, laddr, lport, faddr, fport, ret)
|
||||
);
|
||||
|
||||
struct net_device;
|
||||
DECLARE_HOOK(ninet_gifconf_hook,
|
||||
TP_PROTO(struct net_device *dev, char __user *buf, int len, int size, int *ret),
|
||||
TP_ARGS(dev, buf, len, size, ret)
|
||||
);
|
||||
#endif /* end of _TRACE_HOOK_NIP_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
|
||||
#endif /* end of CONFIG_NEWIP_HOOKS */
|
||||
#endif /* end of CONFIG_NEWIP_HOOKS */
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ source "net/newip/hooks/Kconfig"
|
||||
# net/newip/Kconfig
|
||||
config NEWIP
|
||||
def_bool $(success,$(srctree)/scripts/ohos-check-dir.sh $(srctree)/net/newip)
|
||||
depends on INET
|
||||
depends on INET && NET
|
||||
help
|
||||
Support for NewIP.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# net/newip/Makefile
|
||||
obj-$(CONFIG_NEWIP) += newip.o
|
||||
|
||||
newip-objs := nip_addr.o nip_hdr_encap.o nip_hdr_decap.o nip_checksum.o af_ninet.o nip_input.o udp.o protocol.o nip_output.o nip_addrconf.o nip_addrconf_core.o route.o nip_fib.o nip_fib_rules.o nndisc.o icmp.o tcp_nip_parameter.o
|
||||
newip-objs := nip_addr.o nip_hdr_encap.o nip_hdr_decap.o nip_checksum.o af_ninet.o nip_input.o udp.o protocol.o nip_output.o nip_addrconf.o nip_addrconf_core.o route.o nip_fib.o nip_fib_rules.o nndisc.o icmp.o tcp_nip_parameter.o devninet.o
|
||||
newip-objs += tcp_nip.o ninet_connection_sock.o ninet_hashtables.o tcp_nip_output.o tcp_nip_input.o tcp_nip_timer.o nip_sockglue.o
|
||||
|
||||
newip-objs += nip_hooks_register.o
|
||||
|
||||
@@ -89,7 +89,7 @@ static int ninet_create(struct net *net, struct socket *sock, int protocol,
|
||||
|
||||
num = atomic_add_return(1, &g_nip_socket_number);
|
||||
if (num > NIP_MAX_SOCKET_NUM) {
|
||||
DEBUG("The number of socket is biger than 1024!");
|
||||
nip_dbg("The number of socket is biger than 1024");
|
||||
err = -EPERM;
|
||||
goto number_sub;
|
||||
}
|
||||
@@ -178,14 +178,14 @@ static int ninet_create(struct net *net, struct socket *sock, int protocol,
|
||||
}
|
||||
}
|
||||
out:
|
||||
DEBUG("The final number of socket is: %d", num);
|
||||
nip_dbg("The final number of socket is: %d", num);
|
||||
return err;
|
||||
out_rcu_unlock:
|
||||
rcu_read_unlock();
|
||||
number_sub:
|
||||
atomic_dec_if_positive(&g_nip_socket_number);
|
||||
num = atomic_read(&g_nip_socket_number);
|
||||
DEBUG("The final number of socket is: %d", num);
|
||||
nip_dbg("The final number of socket is: %d", num);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ int ninet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||
return -EACCES;
|
||||
|
||||
if (nip_bind_addr_check(net, &addr->sin_addr) == false) {
|
||||
DEBUG("%s: binding-addr invalid, bitlen=%u.", __func__, addr->sin_addr.bitlen);
|
||||
nip_dbg("%s: binding-addr invalid, bitlen=%u", __func__, addr->sin_addr.bitlen);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
lock_sock(sk);
|
||||
@@ -426,14 +426,14 @@ int ninet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
struct sock *sk = sock->sk;
|
||||
struct net *net = sock_net(sk);
|
||||
|
||||
DEBUG("%s: cmd=0x%x.", __func__, cmd);
|
||||
nip_dbg("%s: cmd=0x%x", __func__, cmd);
|
||||
switch (cmd) {
|
||||
case SIOCADDRT:
|
||||
case SIOCDELRT: {
|
||||
struct nip_rtmsg rtmsg;
|
||||
|
||||
if (copy_from_user(&rtmsg, (void __user *)arg, sizeof(rtmsg))) {
|
||||
DEBUG("%s: fail to copy route cfg data.", __func__);
|
||||
nip_dbg("%s: fail to copy route cfg data", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
return nip_route_ioctl(net, cmd, &rtmsg);
|
||||
@@ -447,7 +447,7 @@ int ninet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
|
||||
default:
|
||||
if (!sk->sk_prot->ioctl) {
|
||||
DEBUG("%s: sock sk_prot ioctl is null, cmd=0x%x.", __func__, cmd);
|
||||
nip_dbg("%s: sock sk_prot ioctl is null, cmd=0x%x", __func__, cmd);
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
return sk->sk_prot->ioctl(sk, cmd, arg);
|
||||
@@ -479,11 +479,11 @@ static int ninet_compat_routing_ioctl(struct sock *sk, unsigned int cmd,
|
||||
get_user(rt.rtmsg_metric, &ur->rtmsg_metric) ||
|
||||
get_user(rt.rtmsg_info, &ur->rtmsg_info) ||
|
||||
get_user(rt.rtmsg_flags, &ur->rtmsg_flags)) {
|
||||
DEBUG("%s: fail to convert input para, cmd=0x%x.", __func__, cmd);
|
||||
nip_dbg("%s: fail to convert input para, cmd=0x%x", __func__, cmd);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
DEBUG("%s: cmd=0x%x.", __func__, cmd);
|
||||
nip_dbg("%s: cmd=0x%x", __func__, cmd);
|
||||
return nip_route_ioctl(sock_net(sk), cmd, &rt);
|
||||
}
|
||||
|
||||
@@ -600,18 +600,18 @@ out:
|
||||
return ret;
|
||||
|
||||
out_permanent:
|
||||
DEBUG("Attempt to override permanent protocol %d", protocol);
|
||||
nip_dbg("Attempt to override permanent protocol %d", protocol);
|
||||
goto out;
|
||||
|
||||
out_illegal:
|
||||
DEBUG("Ignoring attempt to register invalid socket type %d", p->type);
|
||||
nip_dbg("Ignoring attempt to register invalid socket type %d", p->type);
|
||||
goto out;
|
||||
}
|
||||
|
||||
void ninet_unregister_protosw(struct inet_protosw *p)
|
||||
{
|
||||
if (INET_PROTOSW_PERMANENT & p->flags) {
|
||||
DEBUG("Attempt to unregister permanent protocol %d", p->protocol);
|
||||
nip_dbg("Attempt to unregister permanent protocol %d", p->protocol);
|
||||
} else {
|
||||
spin_lock_bh(&inetsw_nip_lock);
|
||||
list_del_rcu(&p->list);
|
||||
@@ -661,13 +661,13 @@ static int __init ninet_init(void)
|
||||
|
||||
sock_skb_cb_check_size(sizeof(struct ninet_skb_parm));
|
||||
|
||||
DEBUG("NET: start to init nip network.");
|
||||
nip_dbg("NET: start to init nip network");
|
||||
/* register the socket-side information for ninet_create */
|
||||
for (r = &inetsw_nip[0]; r < &inetsw_nip[SOCK_MAX]; ++r)
|
||||
INIT_LIST_HEAD(r);
|
||||
|
||||
if (!newip_mod_enabled()) {
|
||||
DEBUG("Loaded, but administratively disabled, reboot required to enable");
|
||||
nip_dbg("Loaded, but administratively disabled, reboot required to enable");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -677,31 +677,31 @@ static int __init ninet_init(void)
|
||||
|
||||
err = proto_register(&nip_udp_prot, 1);
|
||||
if (err) {
|
||||
DEBUG("failed to register udp proto!");
|
||||
nip_dbg("failed to register udp proto");
|
||||
goto out_udp_register_fail;
|
||||
}
|
||||
|
||||
err = sock_register(&ninet_family_ops);
|
||||
if (err) {
|
||||
DEBUG("failed to register newip_family_ops!");
|
||||
nip_dbg("failed to register newip_family_ops");
|
||||
goto out_sock_register_fail;
|
||||
}
|
||||
|
||||
err = register_pernet_subsys(&ninet_net_ops);
|
||||
if (err) {
|
||||
DEBUG("failed to register ninet_net_ops!");
|
||||
nip_dbg("failed to register ninet_net_ops");
|
||||
goto register_pernet_fail;
|
||||
}
|
||||
|
||||
err = nip_icmp_init();
|
||||
if (err) {
|
||||
DEBUG("nip_icmp_init failed!");
|
||||
nip_dbg("nip_icmp_init failed");
|
||||
goto nip_icmp_fail;
|
||||
}
|
||||
|
||||
err = nndisc_init();
|
||||
if (err) {
|
||||
DEBUG("nndisc_init failed!");
|
||||
nip_dbg("nndisc_init failed");
|
||||
goto nndisc_fail;
|
||||
}
|
||||
|
||||
@@ -715,32 +715,32 @@ static int __init ninet_init(void)
|
||||
|
||||
err = nip_udp_init();
|
||||
if (err) {
|
||||
DEBUG("failed to init udp layer!");
|
||||
nip_dbg("failed to init udp layer");
|
||||
goto udp_fail;
|
||||
}
|
||||
|
||||
err = tcp_nip_init();
|
||||
if (err) {
|
||||
DEBUG("failed to init tcp layer!");
|
||||
nip_dbg("failed to init tcp layer");
|
||||
goto tcp_fail;
|
||||
} else {
|
||||
DEBUG("nip_tcp_init ok!");
|
||||
nip_dbg("nip_tcp_init ok");
|
||||
}
|
||||
|
||||
err = nip_packet_init();
|
||||
if (err) {
|
||||
DEBUG("failed to register to l2 layer!");
|
||||
nip_dbg("failed to register to l2 layer");
|
||||
goto nip_packet_fail;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NEWIP_HOOKS
|
||||
err = ninet_hooks_register();
|
||||
if (err) {
|
||||
DEBUG("failed to register to nip hooks");
|
||||
nip_dbg("failed to register to nip hooks");
|
||||
goto nip_packet_fail;
|
||||
}
|
||||
#endif
|
||||
DEBUG("NewIP: init newip address family ok!");
|
||||
nip_dbg("NewIP: init newip address family ok");
|
||||
|
||||
out:
|
||||
return err;
|
||||
@@ -762,7 +762,7 @@ register_pernet_fail:
|
||||
out_sock_register_fail:
|
||||
proto_unregister(&nip_udp_prot);
|
||||
out_udp_register_fail:
|
||||
DEBUG("newip family init failed!!!");
|
||||
nip_dbg("newip family init failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
*
|
||||
* NewIP INET
|
||||
* An implementation of the TCP/IP protocol suite for the LINUX
|
||||
* operating system. NewIP INET is implemented using the BSD Socket
|
||||
* interface as the means of communication with the user level.
|
||||
*
|
||||
* DEVICE - NEWIP device support.
|
||||
* Based on net/ipv4/devinet.c
|
||||
*/
|
||||
#include <net/nip_fib.h>
|
||||
#include <net/nip_addrconf.h>
|
||||
|
||||
int ninet_gifconf(struct net_device *dev, char __user *buf, int len, int size)
|
||||
{
|
||||
struct ninet_dev *nin_dev = __nin_dev_get(dev);
|
||||
const struct ninet_ifaddr *ifa;
|
||||
struct ifreq ifr;
|
||||
int done = 0;
|
||||
|
||||
if (WARN_ON(size > sizeof(struct ifreq)))
|
||||
goto out;
|
||||
if (!nin_dev)
|
||||
goto out;
|
||||
|
||||
list_for_each_entry(ifa, &nin_dev->addr_list, if_list) {
|
||||
ifa = rcu_dereference_protected(ifa, lockdep_is_held(&ifa->lock));
|
||||
if (!ifa) {
|
||||
done = -EFAULT;
|
||||
break;
|
||||
}
|
||||
if (!buf) {
|
||||
done += size;
|
||||
continue;
|
||||
}
|
||||
if (len < size)
|
||||
break;
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
strcpy(ifr.ifr_name, ifa->rt->dst.dev->name);
|
||||
|
||||
(*(struct sockaddr_nin *)&ifr.ifr_addr).sin_family = AF_NINET;
|
||||
memcpy(&((struct sockaddr_nin *)&ifr.ifr_addr)->sin_addr, &ifa->addr,
|
||||
sizeof(struct nip_addr));
|
||||
|
||||
if (copy_to_user(buf + done, &ifr, size)) {
|
||||
done = -EFAULT;
|
||||
break;
|
||||
}
|
||||
len -= size;
|
||||
done += size;
|
||||
}
|
||||
out:
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@
|
||||
|
||||
#ifdef CONFIG_NEWIP_HOOKS
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(ninet_ehashfn_hook);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(ninet_gifconf_hook);
|
||||
#endif
|
||||
|
||||
@@ -36,14 +36,14 @@ int nip_icmp_rcv(struct sk_buff *skb)
|
||||
struct nip_icmp_hdr *hdr = nip_icmp_header(skb);
|
||||
u8 type = hdr->nip_icmp_type;
|
||||
|
||||
DEBUG("rcv newip icmp packet. type = %u\n", type);
|
||||
nip_dbg("rcv newip icmp packet. type = %u", type);
|
||||
switch (type) {
|
||||
case NIP_ARP_NS:
|
||||
case NIP_ARP_NA:
|
||||
ret = nndisc_rcv(skb);
|
||||
break;
|
||||
default:
|
||||
DEBUG("nip icmp packet type error\n");
|
||||
nip_dbg("nip icmp packet type error");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ begin:
|
||||
if (!NINET_MATCH(sk, net, saddr, daddr, ports, dif))
|
||||
continue;
|
||||
if (unlikely(!refcount_inc_not_zero(&sk->sk_refcnt))) {
|
||||
DEBUG("[nip]%s:sk->sk_refcnt == 0!!!!\n", __func__);
|
||||
nip_dbg("[nip]%s:sk->sk_refcnt == 0", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -356,12 +356,12 @@ static struct sock *ninet_lhash2_lookup(struct net *net,
|
||||
sk = (struct sock *)icsk;
|
||||
score = nip_tcp_compute_score(sk, net, hnum, daddr, dif, sdif);
|
||||
if (score > hiscore) {
|
||||
DEBUG("%s: find sock in lhash table", __func__);
|
||||
nip_dbg("%s: find sock in lhash table", __func__);
|
||||
result = sk;
|
||||
hiscore = score;
|
||||
reuseport = sk->sk_reuseport;
|
||||
if (reuseport) {
|
||||
DEBUG("%s: find reuseport sock in lhash table", __func__);
|
||||
nip_dbg("%s: find reuseport sock in lhash table", __func__);
|
||||
phash = ninet_ehashfn(net, daddr, hnum, saddr, sport);
|
||||
matches = 1;
|
||||
}
|
||||
@@ -435,7 +435,7 @@ static int __ninet_check_established(struct inet_timewait_death_row *death_row,
|
||||
|
||||
if (likely(NINET_MATCH(sk2, net,
|
||||
saddr, daddr, ports, dif))) {
|
||||
DEBUG("%s: found same sk in ehash!\n", __func__);
|
||||
nip_dbg("%s: found same sk in ehash", __func__);
|
||||
goto not_unique;
|
||||
}
|
||||
}
|
||||
@@ -443,8 +443,7 @@ static int __ninet_check_established(struct inet_timewait_death_row *death_row,
|
||||
/* Must record num and sport now. Otherwise we will see
|
||||
* in hash table socket with a funny identity.
|
||||
*/
|
||||
DEBUG("%s: add tcp sock into ehash table. sport=%u\n",
|
||||
__func__, lport);
|
||||
nip_dbg("%s: add tcp sock into ehash table. sport=%u", __func__, lport);
|
||||
inet->inet_num = lport;
|
||||
inet->inet_sport = htons(lport);
|
||||
sk->sk_hash = hash;
|
||||
|
||||
@@ -92,34 +92,36 @@ static struct ninet_ifaddr *nip_add_addr(struct ninet_dev *idev,
|
||||
|
||||
if (idev->dead) {
|
||||
err = -ENODEV;
|
||||
goto out2;
|
||||
goto rcu_lock_out;
|
||||
}
|
||||
|
||||
if (idev->cnf.disable_nip) {
|
||||
err = -EACCES;
|
||||
goto out2;
|
||||
goto rcu_lock_out;
|
||||
}
|
||||
|
||||
spin_lock(&addrconf_hash_lock);
|
||||
|
||||
/* Do not configure two same addresses in a netdevice */
|
||||
if (nip_chk_same_addr(dev_net(idev->dev), addr, idev->dev)) {
|
||||
DEBUG("%s: already assigned", __func__);
|
||||
nip_dbg("%s: already assigned", __func__);
|
||||
err = -EEXIST;
|
||||
goto out;
|
||||
goto spin_lock_out;
|
||||
}
|
||||
|
||||
ifa = kzalloc(sizeof(*ifa), GFP_ATOMIC);
|
||||
if (!ifa) {
|
||||
DEBUG("%s: malloc failed", __func__);
|
||||
/* If you add log here, there will be an alarm:
|
||||
* WARNING: Possible unnecessary 'out of memory' message
|
||||
*/
|
||||
err = -ENOBUFS;
|
||||
goto out;
|
||||
goto spin_lock_out;
|
||||
}
|
||||
|
||||
rt = nip_addrconf_dst_alloc(idev, addr);
|
||||
if (IS_ERR(rt)) {
|
||||
err = PTR_ERR(rt);
|
||||
goto out;
|
||||
goto spin_lock_out;
|
||||
}
|
||||
|
||||
neigh_parms_data_state_setall(idev->nd_parms);
|
||||
@@ -152,12 +154,11 @@ static struct ninet_ifaddr *nip_add_addr(struct ninet_dev *idev,
|
||||
nin_ifa_hold(ifa);
|
||||
write_unlock(&idev->lock);
|
||||
|
||||
out2:
|
||||
rcu_lock_out:
|
||||
rcu_read_unlock_bh();
|
||||
|
||||
if (likely(err == 0)) {
|
||||
DEBUG("%s: success! idev->refcnt=%u", __func__,
|
||||
refcount_read(&idev->refcnt));
|
||||
nip_dbg("%s: success, idev->refcnt=%u", __func__, refcount_read(&idev->refcnt));
|
||||
} else {
|
||||
kfree(ifa);
|
||||
nin_dev_put(idev);
|
||||
@@ -165,9 +166,9 @@ out2:
|
||||
}
|
||||
|
||||
return ifa;
|
||||
out:
|
||||
spin_lock_out:
|
||||
spin_unlock(&addrconf_hash_lock);
|
||||
goto out2;
|
||||
goto rcu_lock_out;
|
||||
}
|
||||
|
||||
static struct ninet_dev *nip_add_dev(struct net_device *dev)
|
||||
@@ -201,7 +202,7 @@ static struct ninet_dev *nip_add_dev(struct net_device *dev)
|
||||
|
||||
refcount_set(&ndev->refcnt, 1);
|
||||
|
||||
DEBUG("%s: init ninet_dev success!, set ndev->refcnt=1", __func__);
|
||||
nip_dbg("%s: init ninet_dev success, set ndev->refcnt=1", __func__);
|
||||
|
||||
if (netif_running(dev) && nip_addrconf_link_ready(dev))
|
||||
ndev->if_flags |= IF_READY;
|
||||
@@ -287,7 +288,7 @@ static int ninet_addr_add(struct net *net, int ifindex,
|
||||
if (!IS_ERR(ifp)) {
|
||||
nin_ifa_put(ifp);
|
||||
nip_ins_rt(ifp->rt);
|
||||
DEBUG("%s: success! ifp->refcnt=%u", __func__, refcount_read(&ifp->refcnt));
|
||||
nip_dbg("%s: success, ifp->refcnt=%u", __func__, refcount_read(&ifp->refcnt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -299,8 +300,8 @@ void ninet_ifa_finish_destroy(struct ninet_ifaddr *ifp)
|
||||
{
|
||||
WARN_ON(!hlist_unhashed(&ifp->addr_lst));
|
||||
|
||||
DEBUG("%s: before idev put. idev->refcnt=%u", __func__,
|
||||
refcount_read(&ifp->idev->refcnt));
|
||||
nip_dbg("%s: before idev put. idev->refcnt=%u", __func__,
|
||||
refcount_read(&ifp->idev->refcnt));
|
||||
|
||||
nin_dev_put(ifp->idev);
|
||||
|
||||
@@ -368,7 +369,7 @@ static int ninet_addr_del(struct net *net, int ifindex, u32 ifa_flags,
|
||||
read_unlock_bh(&idev->lock);
|
||||
|
||||
nip_del_addr(ifp);
|
||||
DEBUG("nip_addr_del: success!");
|
||||
nip_dbg("nip_addr_del: success");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -383,22 +384,22 @@ int nip_addrconf_add_ifaddr(struct net *net, void __user *arg)
|
||||
int err;
|
||||
|
||||
if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) {
|
||||
DEBUG("%s: not admin can`t cfg.", __func__);
|
||||
nip_dbg("%s: not admin can`t cfg", __func__);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ireq, arg, sizeof(struct nip_ifreq))) {
|
||||
DEBUG("%s: fail to copy cfg data.", __func__);
|
||||
nip_dbg("%s: fail to copy cfg data", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (nip_addr_invalid(&ireq.ifrn_addr)) {
|
||||
DEBUG("%s: nip addr invalid, bitlen=%u.", __func__, ireq.ifrn_addr.bitlen);
|
||||
nip_dbg("%s: nip addr invalid, bitlen=%u", __func__, ireq.ifrn_addr.bitlen);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (nip_addr_public(&ireq.ifrn_addr)) {
|
||||
DEBUG("%s: The public address cannot be configured.", __func__);
|
||||
nip_dbg("%s: The public address cannot be configured", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
@@ -416,22 +417,22 @@ int nip_addrconf_del_ifaddr(struct net *net, void __user *arg)
|
||||
int err;
|
||||
|
||||
if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) {
|
||||
DEBUG("%s: not admin can`t cfg.", __func__);
|
||||
nip_dbg("%s: not admin can`t cfg", __func__);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ireq, arg, sizeof(struct nip_ifreq))) {
|
||||
DEBUG("%s: fail to copy cfg data.", __func__);
|
||||
nip_dbg("%s: fail to copy cfg data", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (nip_addr_invalid(&ireq.ifrn_addr)) {
|
||||
DEBUG("%s: nip addr invalid, bitlen=%u.", __func__, ireq.ifrn_addr.bitlen);
|
||||
nip_dbg("%s: nip addr invalid, bitlen=%u", __func__, ireq.ifrn_addr.bitlen);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (nip_addr_public(&ireq.ifrn_addr)) {
|
||||
DEBUG("%s: Public addresses cannot be deleted.", __func__);
|
||||
nip_dbg("%s: Public addresses cannot be deleted", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
@@ -507,7 +508,7 @@ static int nip_addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
switch (event) {
|
||||
case NETDEV_REGISTER:
|
||||
if (!idev && dev->mtu >= NIP_MIN_MTU) {
|
||||
DEBUG("NIP_ADDRCONF(NETDEV_REGISTER): ");
|
||||
nip_dbg("NIP_ADDRCONF(NETDEV_REGISTER): ");
|
||||
idev = nip_add_dev(dev);
|
||||
if (IS_ERR(idev))
|
||||
return notifier_from_errno(PTR_ERR(idev));
|
||||
@@ -547,8 +548,8 @@ static int nip_addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
if (event == NETDEV_UP) {
|
||||
if (!nip_addrconf_link_ready(dev)) {
|
||||
/* device is not ready yet. */
|
||||
DEBUG("NIP_ADDRCONF(NETDEV_UP): ");
|
||||
DEBUG("%s:link is not ready", dev->name);
|
||||
nip_dbg("NIP_ADDRCONF(NETDEV_UP)");
|
||||
nip_dbg("%s:link is not ready", dev->name);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -558,16 +559,15 @@ static int nip_addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
if (!IS_ERR_OR_NULL(idev))
|
||||
idev->if_flags |= IF_READY;
|
||||
} else if (event == NETDEV_CHANGE) {
|
||||
if (!nip_addrconf_link_ready(dev)) {
|
||||
if (!nip_addrconf_link_ready(dev))
|
||||
/* device is still not ready. */
|
||||
break;
|
||||
}
|
||||
|
||||
if (idev)
|
||||
idev->if_flags |= IF_READY;
|
||||
|
||||
DEBUG("NIP_ADDRCONF(NETDEV_CHANGE):");
|
||||
DEBUG("%s:link becomes ready", dev->name);
|
||||
nip_dbg("NIP_ADDRCONF(NETDEV_CHANGE)");
|
||||
nip_dbg("%s:link becomes ready", dev->name);
|
||||
}
|
||||
|
||||
if (!IS_ERR_OR_NULL(idev)) {
|
||||
@@ -575,10 +575,8 @@ static int nip_addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
* when the interface up, the changed MTU must be
|
||||
* reflected in the idev as well as routers.
|
||||
*/
|
||||
if (idev->cnf.mtu != dev->mtu &&
|
||||
dev->mtu >= NIP_MIN_MTU) {
|
||||
if (idev->cnf.mtu != dev->mtu && dev->mtu >= NIP_MIN_MTU)
|
||||
idev->cnf.mtu = dev->mtu;
|
||||
}
|
||||
idev->tstamp = jiffies;
|
||||
|
||||
/* If the changed mtu during down is lower than
|
||||
@@ -611,8 +609,8 @@ static int nip_addrconf_ifdown(struct net_device *dev, bool unregister)
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
DEBUG("%s: %s ifindex=%u, unregister=%u (unregister:1, down:0)",
|
||||
__func__, dev->name, dev->ifindex, unregister);
|
||||
nip_dbg("%s: %s ifindex=%u, unregister=%u (unregister:1, down:0)",
|
||||
__func__, dev->name, dev->ifindex, unregister);
|
||||
|
||||
nip_rt_ifdown(net, dev);
|
||||
neigh_ifdown(&nnd_tbl, dev);
|
||||
@@ -639,7 +637,7 @@ static int nip_addrconf_ifdown(struct net_device *dev, bool unregister)
|
||||
char addr[NIP_ADDR_BIT_LEN_MAX] = {0};
|
||||
|
||||
nip_addr_to_str(&ifa->addr, addr, NIP_ADDR_BIT_LEN_MAX);
|
||||
DEBUG("%s: clear addr hash table.(addr=%s)", __func__, addr);
|
||||
nip_dbg("%s: clear addr hash table.(addr=%s)", __func__, addr);
|
||||
hlist_del_init_rcu(&ifa->addr_lst);
|
||||
}
|
||||
}
|
||||
@@ -678,8 +676,8 @@ static int nip_addrconf_ifdown(struct net_device *dev, bool unregister)
|
||||
if (unregister) {
|
||||
neigh_parms_release(&nnd_tbl, idev->nd_parms);
|
||||
neigh_ifdown(&nnd_tbl, dev);
|
||||
DEBUG("%s: %s (ifindex=%u) before idev put. idev->refcnt=%u", __func__,
|
||||
dev->name, dev->ifindex, refcount_read(&idev->refcnt));
|
||||
nip_dbg("%s: %s (ifindex=%u) before idev put. idev->refcnt=%u", __func__,
|
||||
dev->name, dev->ifindex, refcount_read(&idev->refcnt));
|
||||
nin_dev_put(idev);
|
||||
}
|
||||
return 0;
|
||||
@@ -692,20 +690,16 @@ static int nip_addr_proc_show(struct seq_file *seq, void *v)
|
||||
int i, j;
|
||||
|
||||
rcu_read_lock();
|
||||
for (i = 0; i < NIN_ADDR_HSIZE; i++) {
|
||||
for (i = 0; i < NIN_ADDR_HSIZE; i++)
|
||||
hlist_for_each_entry_rcu(ifp, &ninet_addr_lst[i], addr_lst) {
|
||||
if (!net_eq(dev_net(ifp->idev->dev), net))
|
||||
continue;
|
||||
|
||||
for (j = 0; j < ifp->addr.bitlen / NIP_ADDR_BIT_LEN_8;
|
||||
j++) {
|
||||
seq_printf(seq, "%02x",
|
||||
ifp->addr.nip_addr_field8[j]);
|
||||
}
|
||||
seq_printf(seq, "\t%8s\n",
|
||||
ifp->idev->dev ? ifp->idev->dev->name : "");
|
||||
for (j = 0; j < ifp->addr.bitlen / NIP_ADDR_BIT_LEN_8; j++)
|
||||
seq_printf(seq, "%02x", ifp->addr.nip_addr_field8[j]);
|
||||
seq_printf(seq, "\t%8s\n", ifp->idev->dev ? ifp->idev->dev->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
rcu_read_unlock();
|
||||
return 0;
|
||||
}
|
||||
@@ -760,7 +754,7 @@ int __init nip_addrconf_init(void)
|
||||
|
||||
err = register_pernet_subsys(&nip_route_proc_net_ops);
|
||||
if (err < 0) {
|
||||
DEBUG("%s: register_pernet_subsys failed!", __func__);
|
||||
nip_dbg("%s: register_pernet_subsys failed", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -823,7 +817,7 @@ int nip_addrconf_get_ifaddr(struct net *net, unsigned int cmd, void __user *arg)
|
||||
ifr.nip_ifr_name[IFNAMSIZ - 1] = 0;
|
||||
snin = (struct sockaddr_nin *)&ifr.nip_dev_addr;
|
||||
|
||||
DEBUG("%s, dev name is %s", __func__, ifr.nip_ifr_name);
|
||||
nip_dbg("%s, dev name is %s", __func__, ifr.nip_ifr_name);
|
||||
dev_load(net, ifr.nip_ifr_name);
|
||||
|
||||
if (cmd == SIOCGIFADDR) {
|
||||
|
||||
@@ -94,10 +94,8 @@ struct nip_fib_node *nip_fib_locate(struct hlist_head *nip_tb_head,
|
||||
h = &nip_tb_head[hash];
|
||||
|
||||
hlist_for_each_entry_rcu(fib_node, h, fib_hlist) {
|
||||
if (nip_addr_eq
|
||||
(&fib_node->nip_route_info->rt_dst, &nip_any_addr)) {
|
||||
if (nip_addr_eq(&fib_node->nip_route_info->rt_dst, &nip_any_addr))
|
||||
return fib_node;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -126,7 +124,7 @@ int nip_fib_add(struct hlist_head *nip_tb_head, struct nip_rt_info *rt)
|
||||
|
||||
new_node = nip_node_alloc();
|
||||
if (!new_node) {
|
||||
DEBUG("%s: fail to alloc mem.", __func__);
|
||||
nip_dbg("%s: fail to alloc mem", __func__);
|
||||
err = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
@@ -201,8 +199,8 @@ static void nip_fib_clean_hash(struct net *net, struct hlist_head *nip_tb_head,
|
||||
nip_addr_to_str(&fn->nip_route_info->gateway, gateway,
|
||||
NIP_ADDR_BIT_LEN_MAX);
|
||||
|
||||
DEBUG("%s: try to del rt_info, rt_dst=%s, gateway=%s",
|
||||
__func__, dst, gateway);
|
||||
nip_dbg("%s: try to del rt_info, rt_dst=%s, gateway=%s",
|
||||
__func__, dst, gateway);
|
||||
nip_fib_del(fn->nip_route_info, &info);
|
||||
}
|
||||
}
|
||||
@@ -284,8 +282,8 @@ int __init nip_fib_init(void)
|
||||
if (!nip_fib_node_kmem)
|
||||
goto out;
|
||||
|
||||
DEBUG("nip_fib_node size is %lu",
|
||||
sizeof(struct nip_fib_node) + sizeof(struct nip_rt_info));
|
||||
nip_dbg("nip_fib_node size is %lu",
|
||||
sizeof(struct nip_fib_node) + sizeof(struct nip_rt_info));
|
||||
|
||||
ret = register_pernet_subsys(&nip_fib_net_ops);
|
||||
if (ret)
|
||||
|
||||
@@ -8,22 +8,35 @@
|
||||
#define pr_fmt(fmt) "NIP: " fmt
|
||||
|
||||
#include <net/ninet_hashtables.h> /* ninet_ehashfn */
|
||||
#include <net/if_ninet.h>
|
||||
#include <trace/hooks/nip_hooks.h>
|
||||
|
||||
void ninet_ehashfn_hook(void *data, const struct net *net,
|
||||
const struct nip_addr *laddr, const u16 lport,
|
||||
const struct nip_addr *faddr, const __be16 fport, u32 *ret)
|
||||
const struct nip_addr *laddr, const u16 lport,
|
||||
const struct nip_addr *faddr, const __be16 fport, u32 *ret)
|
||||
{
|
||||
*ret = ninet_ehashfn(net, laddr, lport, faddr, fport);
|
||||
}
|
||||
|
||||
void ninet_gifconf_hook(void *data, struct net_device *dev,
|
||||
char __user *buf, int len, int size, int *ret)
|
||||
{
|
||||
*ret = ninet_gifconf(dev, buf, len, size);
|
||||
}
|
||||
|
||||
int ninet_hooks_register(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = register_trace_ninet_ehashfn_hook(&ninet_ehashfn_hook, NULL);
|
||||
if (ret) {
|
||||
DEBUG("failed to register to ninet_ehashfn_hook");
|
||||
nip_dbg("failed to register to ninet_ehashfn_hook");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = register_trace_ninet_gifconf_hook(&ninet_gifconf_hook, NULL);
|
||||
if (ret) {
|
||||
nip_dbg("failed to register to ninet_gifconf_hook");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ static int _nip_update_recv_skb_len(struct sk_buff *skb,
|
||||
return 0;
|
||||
|
||||
if (niph->total_len > skb->len) {
|
||||
DEBUG("%s: total_len(%u) is bigger than skb_len(%u), Drop a packet.",
|
||||
__func__, niph->total_len, skb->len);
|
||||
nip_dbg("%s: total_len(%u) is bigger than skb_len(%u), Drop a packet",
|
||||
__func__, niph->total_len, skb->len);
|
||||
return NET_RX_DROP;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ static int nip_rcv_finish(struct sk_buff *skb)
|
||||
if (net->ipv4.sysctl_ip_early_demux && !skb_dst(skb) && !skb->sk) {
|
||||
const struct ninet_protocol *ipprot;
|
||||
|
||||
DEBUG("%s: try to early demux skb, nexthdr=0x%x.", __func__, NIPCB(skb)->nexthdr);
|
||||
nip_dbg("%s: try to early demux skb, nexthdr=0x%x", __func__, NIPCB(skb)->nexthdr);
|
||||
ipprot = rcu_dereference(ninet_protos[NIPCB(skb)->nexthdr]);
|
||||
if (ipprot)
|
||||
edemux = READ_ONCE(ipprot->early_demux);
|
||||
@@ -87,14 +87,14 @@ int nip_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
memset(NIPCB(skb), 0, sizeof(struct ninet_skb_parm));
|
||||
offset = nip_hdr_parse(skb->data, skb->len, &niph);
|
||||
if (offset <= 0) {
|
||||
DEBUG("%s check in failure, errcode=%d, Drop a packet.(nexthdr=%u, hdr_len=%u)",
|
||||
__func__, offset, niph.nexthdr, niph.hdr_len);
|
||||
nip_dbg("%s check in failure, errcode=%d, Drop a packet (nexthdr=%u, hdr_len=%u)",
|
||||
__func__, offset, niph.nexthdr, niph.hdr_len);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
if (niph.nexthdr != IPPROTO_UDP && niph.nexthdr != IPPROTO_TCP &&
|
||||
niph.nexthdr != IPPROTO_NIP_ICMP) {
|
||||
DEBUG("%s nexthdr(%u) invalid, Drop a packet.", __func__, niph.nexthdr);
|
||||
nip_dbg("%s nexthdr(%u) invalid, Drop a packet", __func__, niph.nexthdr);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void nip_protocol_deliver_rcu(struct sk_buff *skb)
|
||||
ipprot->handler(skb);
|
||||
} else {
|
||||
kfree_skb(skb);
|
||||
DEBUG("not found transport protol, drop this packet!");
|
||||
nip_dbg("not found transport protol, drop this packet");
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void update_memory_rate(const char *upper_fun)
|
||||
total = (unsigned long)mem_info.totalram * uint_kb;
|
||||
free = (unsigned long)mem_info.freeram * uint_kb;
|
||||
used = total - free;
|
||||
DEBUG("%s -> %s mem total: %ld KB, mem used: %ld KB", upper_fun, __func__, total, used);
|
||||
nip_dbg("%s -> %s mem total: %ld KB, mem used: %ld KB", upper_fun, __func__, total, used);
|
||||
}
|
||||
|
||||
int nip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
@@ -76,7 +76,7 @@ int nip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
|
||||
rcu_read_unlock_bh();
|
||||
return res;
|
||||
}
|
||||
DEBUG("find neigh and create neigh failed!");
|
||||
nip_dbg("find neigh and create neigh failed");
|
||||
|
||||
rcu_read_unlock_bh();
|
||||
kfree_skb(skb);
|
||||
@@ -106,7 +106,7 @@ int nip_send_skb(struct sk_buff *skb)
|
||||
if (err) {
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
DEBUG("%s: failed to out skb! err = %d", __func__, err);
|
||||
nip_dbg("%s: failed to out skb, err = %d", __func__, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -139,7 +139,7 @@ static struct sk_buff *_nip_alloc_skb(struct sock *sk,
|
||||
len = NIP_ETH_HDR_LEN + nip_hdr_len + head->trans_hdr_len + seg_info->mid_usr_pkt_len;
|
||||
skb = alloc_skb(len, 0);
|
||||
if (!skb) {
|
||||
DEBUG("%s: no space for skb", __func__);
|
||||
nip_dbg("%s: no space for skb", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ static struct sk_buff *_nip_alloc_skb(struct sock *sk,
|
||||
skb->sk = sk;
|
||||
|
||||
dst_hold(dst);
|
||||
DEBUG("%s: malloc_len=%d, dst->__refcnt=%u", __func__,
|
||||
len, atomic_read(&dst->__refcnt));
|
||||
nip_dbg("%s: malloc_len=%d, dst->__refcnt=%u", __func__,
|
||||
len, atomic_read(&dst->__refcnt));
|
||||
skb_dst_set(skb, dst);
|
||||
memset(NIPCB(skb), 0, sizeof(struct ninet_skb_parm));
|
||||
|
||||
@@ -169,7 +169,7 @@ static int _nip_udp_single_output(struct sock *sk,
|
||||
unsigned short check = 0;
|
||||
|
||||
if (IS_ERR_OR_NULL(skb)) {
|
||||
DEBUG("%s: skb alloc fail", __func__);
|
||||
nip_dbg("%s: skb alloc fail", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -198,8 +198,7 @@ static int _nip_udp_single_output(struct sock *sk,
|
||||
/* The DST has been set to the SKB. When the SKB is released,
|
||||
* the DST is automatically released
|
||||
*/
|
||||
DEBUG("%s: copy from iter fail.(datalen=%u)",
|
||||
__func__, head->usr_data_len);
|
||||
nip_dbg("%s: copy from iter fail (datalen=%u)", __func__, head->usr_data_len);
|
||||
kfree_skb(skb);
|
||||
return -EFBIG;
|
||||
}
|
||||
@@ -225,8 +224,7 @@ static int _nip_udp_single_output(struct sock *sk,
|
||||
skb->priority = sk->sk_priority;
|
||||
|
||||
ret = nip_send_skb(skb);
|
||||
DEBUG("%s: newip output finish.(ret=%d, datalen=%u)",
|
||||
__func__, ret, head->usr_data_len);
|
||||
nip_dbg("%s: newip output finish (ret=%d, datalen=%u)", __func__, ret, head->usr_data_len);
|
||||
update_memory_rate(__func__);
|
||||
return ret;
|
||||
}
|
||||
@@ -304,7 +302,7 @@ static int nip_dst_lookup_tail(struct net *net, const struct sock *sk,
|
||||
err = (*dst)->error;
|
||||
if (err) {
|
||||
rt = NULL;
|
||||
DEBUG("%s: nip_route_output search error!", __func__);
|
||||
nip_dbg("%s: nip_route_output search error", __func__);
|
||||
goto out_err_release;
|
||||
}
|
||||
|
||||
@@ -389,10 +387,13 @@ int tcp_nip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
|
||||
fln.daddr = sk->sk_nip_daddr;
|
||||
dst = __sk_dst_check(sk, 0);
|
||||
if (!dst) {
|
||||
DEBUG("%s: no dst cache for sk, search newip rt.", __func__);
|
||||
nip_dbg("%s: no dst cache for sk, search newip rt", __func__);
|
||||
dst = nip_route_output(net, sk, &fln);
|
||||
err = dst->error;
|
||||
if (err)
|
||||
goto out_err_release;
|
||||
if (!dst) {
|
||||
DEBUG("%s: cannot find dst.", __func__);
|
||||
nip_dbg("%s: cannot find dst", __func__);
|
||||
goto out;
|
||||
}
|
||||
sk_dst_set(sk, dst);
|
||||
@@ -412,13 +413,21 @@ int tcp_nip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
|
||||
head.total_len = skb->len;
|
||||
err = nip_send_skb(skb);
|
||||
if (err)
|
||||
DEBUG("%s: failed to send skb, skb->len=%u", __func__, head.total_len);
|
||||
nip_dbg("%s: failed to send skb, skb->len=%u", __func__, head.total_len);
|
||||
else
|
||||
DEBUG("%s: send skb ok, skb->len=%u", __func__, head.total_len);
|
||||
nip_dbg("%s: send skb ok, skb->len=%u", __func__, head.total_len);
|
||||
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
return err;
|
||||
|
||||
out_err_release:
|
||||
dst_release(dst);
|
||||
dst = NULL;
|
||||
sk->sk_err_soft = -err;
|
||||
sk->sk_route_caps = 0;
|
||||
kfree_skb(skb);
|
||||
return err;
|
||||
}
|
||||
|
||||
void tcp_nip_actual_send_reset(struct sock *sk, struct sk_buff *skb, u32 seq,
|
||||
@@ -440,10 +449,12 @@ void tcp_nip_actual_send_reset(struct sock *sk, struct sk_buff *skb, u32 seq,
|
||||
|
||||
/* alloc skb */
|
||||
buff = alloc_skb(MAX_TCP_HEADER, priority);
|
||||
if (!buff) {
|
||||
DEBUG("%s: alloc_skb failed.", __func__);
|
||||
if (!buff)
|
||||
/* If you add log here, there will be an alarm:
|
||||
* WARNING: Possible unnecessary 'out of memory' message
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
skb_reserve(buff, MAX_TCP_HEADER);
|
||||
|
||||
buff->sk = sk; // sk could be NULL
|
||||
@@ -463,10 +474,10 @@ void tcp_nip_actual_send_reset(struct sock *sk, struct sk_buff *skb, u32 seq,
|
||||
t1->rst = rst;
|
||||
t1->window = htons(win);
|
||||
t1->check = htons(nip_get_output_checksum_tcp(buff, *saddr, *daddr));
|
||||
DEBUG("%s: host dport=%u, net dport=0x%x, host sport=%u, net sport=0x%x",
|
||||
__func__, ntohs(t1->dest), t1->dest, ntohs(t1->source), t1->source);
|
||||
DEBUG("%s: host seq=%u, net seq=0x%x, host ack_seq=%u, net ack_seq=0x%x",
|
||||
__func__, seq, t1->seq, ack_seq, t1->ack_seq);
|
||||
nip_dbg("%s: host dport=%u, net dport=0x%x, host sport=%u, net sport=0x%x",
|
||||
__func__, ntohs(t1->dest), t1->dest, ntohs(t1->source), t1->source);
|
||||
nip_dbg("%s: host seq=%u, net seq=0x%x, host ack_seq=%u, net ack_seq=0x%x",
|
||||
__func__, seq, t1->seq, ack_seq, t1->ack_seq);
|
||||
|
||||
buff->protocol = htons(ETH_P_NEWIP);
|
||||
buff->ip_summed = CHECKSUM_NONE;
|
||||
@@ -486,7 +497,7 @@ void tcp_nip_actual_send_reset(struct sock *sk, struct sk_buff *skb, u32 seq,
|
||||
fln.daddr = *daddr;
|
||||
dst = nip_route_output(net, sk, &fln); // here, sk not used.
|
||||
if (!dst) {
|
||||
DEBUG("%s: cannot find dst.", __func__);
|
||||
nip_dbg("%s: cannot find dst", __func__);
|
||||
goto out;
|
||||
}
|
||||
skb_dst_set_noref(buff, dst);
|
||||
@@ -504,9 +515,9 @@ void tcp_nip_actual_send_reset(struct sock *sk, struct sk_buff *skb, u32 seq,
|
||||
head.total_len = buff->len;
|
||||
err = nip_send_skb(buff);
|
||||
if (err)
|
||||
DEBUG("%s: failed to send skb, skb->len=%u", __func__, head.total_len);
|
||||
nip_dbg("%s: failed to send skb, skb->len=%u", __func__, head.total_len);
|
||||
else
|
||||
DEBUG("%s: send skb ok, skb->len=%u", __func__, head.total_len);
|
||||
nip_dbg("%s: send skb ok, skb->len=%u", __func__, head.total_len);
|
||||
|
||||
out:
|
||||
return;
|
||||
|
||||
@@ -286,10 +286,11 @@ static void nndisc_send_ns(struct net_device *dev,
|
||||
head.nexthdr = IPPROTO_NIP_ICMP;
|
||||
|
||||
skb = alloc_skb(len, 0);
|
||||
if (!skb) {
|
||||
DEBUG("%s: no space for skbuff!", __func__);
|
||||
if (!skb)
|
||||
/* If you add log here, there will be an alarm:
|
||||
* WARNING: Possible unnecessary 'out of memory' message
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
skb->protocol = htons(ETH_P_NEWIP);
|
||||
skb->dev = dev;
|
||||
@@ -336,7 +337,7 @@ static void nndisc_send_ns(struct net_device *dev,
|
||||
/* DST is set to SKB, and output is used to release SKB regardless of success or failure */
|
||||
ret = dst_output(net, sk, skb);
|
||||
if (ret)
|
||||
DEBUG("%s: dst output fail.", __func__);
|
||||
nip_dbg("%s: dst output fail", __func__);
|
||||
}
|
||||
|
||||
static void nndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
|
||||
@@ -365,7 +366,7 @@ static void nndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
|
||||
}
|
||||
read_unlock_bh(&idev->lock);
|
||||
} else {
|
||||
DEBUG("%s:idev don't exist.", __func__);
|
||||
nip_dbg("%s:idev don't exist", __func__);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
@@ -413,10 +414,12 @@ static void nndisc_send_na(struct net_device *dev,
|
||||
head.nexthdr = IPPROTO_NIP_ICMP;
|
||||
|
||||
skb = alloc_skb(len, 0);
|
||||
if (!skb) {
|
||||
DEBUG("%s: no space for skbuff!", __func__);
|
||||
if (!skb)
|
||||
/* If you add log here, there will be an alarm:
|
||||
* WARNING: Possible unnecessary 'out of memory' message
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
skb->protocol = htons(ETH_P_NEWIP);
|
||||
skb->ip_summed = csummode;
|
||||
skb->csum = 0;
|
||||
@@ -462,7 +465,7 @@ static void nndisc_send_na(struct net_device *dev,
|
||||
skb_dst_set(skb, dst);
|
||||
ret = dst_output(dev_net(skb->dev), sk, skb);
|
||||
if (ret)
|
||||
DEBUG("%s: dst output fail.", __func__);
|
||||
nip_dbg("%s: dst output fail", __func__);
|
||||
}
|
||||
|
||||
bool nip_addr_local(struct net_device *dev, struct nip_addr *addr)
|
||||
@@ -504,13 +507,13 @@ int nndisc_rcv_ns(struct sk_buff *skb)
|
||||
|
||||
p = decode_nip_addr(p, &addr);
|
||||
if (!p) {
|
||||
DEBUG("failure when decode source address!");
|
||||
nip_dbg("failure when decode source address");
|
||||
err = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (nip_addr_invalid(&addr)) {
|
||||
DEBUG("%s: icmp hdr addr invalid, bitlen=%u.", __func__, addr.bitlen);
|
||||
nip_dbg("%s: icmp hdr addr invalid, bitlen=%u", __func__, addr.bitlen);
|
||||
err = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
@@ -525,7 +528,7 @@ int nndisc_rcv_ns(struct sk_buff *skb)
|
||||
|
||||
/* checksum parse*/
|
||||
if (!nip_get_nndisc_rcv_checksum(skb, p)) {
|
||||
DEBUG("%s:ns ICMP checksum failed, drop the packet", __func__);
|
||||
nip_dbg("%s:ns ICMP checksum failed, drop the packet", __func__);
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -533,8 +536,7 @@ int nndisc_rcv_ns(struct sk_buff *skb)
|
||||
neigh = __neigh_lookup(&nnd_tbl, &NIPCB(skb)->srcaddr, dev, lladdr ||
|
||||
!dev->addr_len);
|
||||
if (neigh) {
|
||||
neigh_update(neigh, lladdr, NUD_STALE, NEIGH_UPDATE_F_OVERRIDE,
|
||||
0);
|
||||
neigh_update(neigh, lladdr, NUD_STALE, NEIGH_UPDATE_F_OVERRIDE, 0);
|
||||
neigh_release(neigh);
|
||||
}
|
||||
|
||||
@@ -559,16 +561,14 @@ int nndisc_rcv_na(struct sk_buff *skb)
|
||||
memcpy(lladdr, p, len);
|
||||
|
||||
if (!nip_get_nndisc_rcv_checksum(skb, p + len)) {
|
||||
DEBUG("%s:na ICMP checksum failed! drop the packet!"
|
||||
, __func__);
|
||||
nip_dbg("%s:na ICMP checksum failed, drop the packet", __func__);
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
neigh = neigh_lookup(&nnd_tbl, &NIPCB(skb)->srcaddr, dev);
|
||||
if (neigh) {
|
||||
neigh_update(neigh, lladdr, NUD_REACHABLE,
|
||||
NEIGH_UPDATE_F_OVERRIDE, 0);
|
||||
neigh_update(neigh, lladdr, NUD_REACHABLE, NEIGH_UPDATE_F_OVERRIDE, 0);
|
||||
neigh_release(neigh);
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
@@ -591,7 +591,7 @@ int nndisc_rcv(struct sk_buff *skb)
|
||||
ret = nndisc_rcv_na(skb);
|
||||
break;
|
||||
default:
|
||||
DEBUG("arp packet type error");
|
||||
nip_dbg("nd packet type error");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
+29
-35
@@ -267,7 +267,7 @@ void nip_route_input(struct sk_buff *skb)
|
||||
};
|
||||
|
||||
if (nip_addr_eq(&fln.daddr, &nip_broadcast_addr_arp)) {
|
||||
DEBUG("%s: recv broadcast packet!", __func__);
|
||||
nip_dbg("%s: recv broadcast packet", __func__);
|
||||
dst_hold(&net->newip.nip_broadcast_entry->dst);
|
||||
skb_dst_set(skb,
|
||||
(struct dst_entry *)net->newip.nip_broadcast_entry);
|
||||
@@ -328,7 +328,7 @@ struct nip_rt_info *nip_pol_route(struct net *net, struct nip_fib_table *table,
|
||||
fn = nip_fib_locate(table->nip_tb_head, &fln->daddr);
|
||||
if (!fn) {
|
||||
rcu_read_unlock_bh();
|
||||
DEBUG("%s: search fail!\n", __func__);
|
||||
nip_dbg("%s: search fail", __func__);
|
||||
rt = net->newip.nip_null_entry;
|
||||
dst_hold_and_use(&rt->dst, jiffies);
|
||||
return rt;
|
||||
@@ -339,12 +339,10 @@ struct nip_rt_info *nip_pol_route(struct net *net, struct nip_fib_table *table,
|
||||
rt->dst.lastuse = jiffies;
|
||||
rt->dst.__use++;
|
||||
pcpu_rt = nip_rt_get_pcpu_route(rt);
|
||||
|
||||
DEBUG("%s: cpu id = %d", __func__, smp_processor_id());
|
||||
|
||||
nip_dbg("%s: cpu id=%d", __func__, smp_processor_id());
|
||||
if (pcpu_rt) {
|
||||
rcu_read_unlock_bh();
|
||||
DEBUG("%s: pcpu found!", __func__);
|
||||
nip_dbg("%s: pcpu found", __func__);
|
||||
} else {
|
||||
dst_hold(&rt->dst);
|
||||
rcu_read_unlock_bh();
|
||||
@@ -352,9 +350,9 @@ struct nip_rt_info *nip_pol_route(struct net *net, struct nip_fib_table *table,
|
||||
dst_release(&rt->dst);
|
||||
}
|
||||
|
||||
DEBUG("%s: rt dst.__refcnt = %d ; pcpu dst.__refcnt = %d", __func__,
|
||||
atomic_read(&rt->dst.__refcnt),
|
||||
atomic_read(&pcpu_rt->dst.__refcnt));
|
||||
nip_dbg("%s: rt dst.__refcnt=%d, pcpu dst.__refcnt=%d", __func__,
|
||||
atomic_read(&rt->dst.__refcnt),
|
||||
atomic_read(&pcpu_rt->dst.__refcnt));
|
||||
return pcpu_rt;
|
||||
}
|
||||
|
||||
@@ -365,12 +363,12 @@ bool nip_bind_addr_check(struct net *net,
|
||||
struct nip_fib_table *fib_tbl = net->newip.nip_fib_local_tbl;
|
||||
|
||||
if (nip_addr_invalid(addr)) {
|
||||
DEBUG("%s: binding-addr invalid, bitlen=%u.", __func__, addr->bitlen);
|
||||
nip_dbg("%s: binding-addr invalid, bitlen=%u", __func__, addr->bitlen);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nip_addr_eq(addr, &nip_any_addr)) {
|
||||
DEBUG("%s: binding-addr is any addr.", __func__);
|
||||
nip_dbg("%s: binding-addr is any addr", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -378,11 +376,11 @@ bool nip_bind_addr_check(struct net *net,
|
||||
fn = nip_fib_locate(fib_tbl->nip_tb_head, addr);
|
||||
rcu_read_unlock_bh();
|
||||
if (!fn) {
|
||||
DEBUG("%s: binding-addr is not local addr.", __func__);
|
||||
nip_dbg("%s: binding-addr is not local addr", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG("%s: binding-addr is local addr.", __func__);
|
||||
nip_dbg("%s: binding-addr is local addr", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -398,14 +396,14 @@ static struct nip_rt_info *nip_route_info_create(struct nip_fib_config *cfg)
|
||||
/* find net_device */
|
||||
dev = dev_get_by_index(net, cfg->fc_ifindex);
|
||||
if (!dev) {
|
||||
DEBUG("%s: fail to get dev by ifindex(%u).", __func__, cfg->fc_ifindex);
|
||||
nip_dbg("%s: fail to get dev by ifindex(%u)", __func__, cfg->fc_ifindex);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* find ninet_dev,which has the newip address list */
|
||||
idev = nin_dev_get(dev);
|
||||
if (!idev) {
|
||||
DEBUG("%s: fail to get ninet dev.(ifindex=%u)", __func__, cfg->fc_ifindex);
|
||||
nip_dbg("%s: fail to get ninet dev (ifindex=%u)", __func__, cfg->fc_ifindex);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -415,13 +413,13 @@ static struct nip_rt_info *nip_route_info_create(struct nip_fib_config *cfg)
|
||||
err = -ENOBUFS;
|
||||
table = nip_fib_get_table(net, cfg->fc_table);
|
||||
if (!table) {
|
||||
DEBUG("%s: fail to get fib table.(fc_table=%u)", __func__, cfg->fc_table);
|
||||
nip_dbg("%s: fail to get fib table (fc_table=%u)", __func__, cfg->fc_table);
|
||||
goto out;
|
||||
}
|
||||
|
||||
rt = nip_dst_alloc(net, NULL, (cfg->fc_flags & RTF_ADDRCONF) ? 0 : DST_NOCOUNT);
|
||||
if (!rt) {
|
||||
DEBUG("%s: fail to alloc dst mem.", __func__);
|
||||
nip_dbg("%s: fail to alloc dst mem", __func__);
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@@ -434,10 +432,10 @@ static struct nip_rt_info *nip_route_info_create(struct nip_fib_config *cfg)
|
||||
|
||||
if (cfg->fc_flags & RTF_LOCAL) {
|
||||
rt->dst.input = nip_input;
|
||||
DEBUG("rt->dst.input = nip_input, ifindex=%u", cfg->fc_ifindex);
|
||||
nip_dbg("rt->dst.input=nip_input, ifindex=%u", cfg->fc_ifindex);
|
||||
} else {
|
||||
rt->dst.input = nip_forward;
|
||||
DEBUG("rt->dst.input = nip_forward, ifindex=%u", cfg->fc_ifindex);
|
||||
nip_dbg("rt->dst.input=nip_forward, ifindex=%u", cfg->fc_ifindex);
|
||||
}
|
||||
|
||||
rt->dst.output = nip_output;
|
||||
@@ -496,7 +494,7 @@ int nip_route_add(struct nip_fib_config *cfg)
|
||||
|
||||
rt = nip_route_info_create(cfg);
|
||||
if (IS_ERR(rt)) {
|
||||
DEBUG("%s: fail to creat route info.", __func__);
|
||||
nip_dbg("%s: fail to creat route info", __func__);
|
||||
err = PTR_ERR(rt);
|
||||
rt = NULL;
|
||||
goto out;
|
||||
@@ -568,21 +566,20 @@ int nip_route_ioctl(struct net *net, unsigned int cmd, struct nip_rtmsg *rtmsg)
|
||||
int err;
|
||||
|
||||
if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) {
|
||||
DEBUG("%s: not admin can`t cfg.", __func__);
|
||||
nip_dbg("%s: not admin can`t cfg", __func__);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
rtmsg_to_fibni_config(net, rtmsg, &cfg);
|
||||
if (nip_addr_invalid(&cfg.fc_dst)) {
|
||||
DEBUG("%s: nip daddr invalid, bitlen=%u",
|
||||
__func__, cfg.fc_dst.bitlen);
|
||||
nip_dbg("%s: nip daddr invalid, bitlen=%u", __func__, cfg.fc_dst.bitlen);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (cfg.fc_flags & RTF_GATEWAY) {
|
||||
if (nip_addr_invalid(&cfg.fc_gateway)) {
|
||||
DEBUG("%s: nip gateway daddr invalid, bitlen=%u",
|
||||
__func__, cfg.fc_gateway.bitlen);
|
||||
nip_dbg("%s: nip gateway daddr invalid, bitlen=%u",
|
||||
__func__, cfg.fc_gateway.bitlen);
|
||||
return -EFAULT;
|
||||
}
|
||||
}
|
||||
@@ -615,15 +612,12 @@ static void nip_dst_destroy(struct dst_entry *dst)
|
||||
idev = rt->rt_idev;
|
||||
if (idev) {
|
||||
rt->rt_idev = NULL;
|
||||
DEBUG("%s: idev->refcnt=%u\n", __func__,
|
||||
refcount_read(&idev->refcnt));
|
||||
nip_dbg("%s: idev->refcnt=%u", __func__, refcount_read(&idev->refcnt));
|
||||
nin_dev_put(idev);
|
||||
}
|
||||
|
||||
if (from) {
|
||||
DEBUG("%s: from->__refcnt = %d", __func__,
|
||||
atomic_read(&from->__refcnt));
|
||||
}
|
||||
if (from)
|
||||
nip_dbg("%s: from->__refcnt=%d", __func__, atomic_read(&from->__refcnt));
|
||||
rt->from = NULL;
|
||||
dst_release(from);
|
||||
}
|
||||
@@ -785,10 +779,10 @@ static int nip_fib_ifdown(struct nip_rt_info *rt, void *arg)
|
||||
(dev_unregister || ignore_route_ifdown))
|
||||
return -1;
|
||||
|
||||
DEBUG("%s: don`t del route with %s down, ifindex=%u, not_same_dev=%u, not_null_entry=%u",
|
||||
__func__, dev->name, dev->ifindex, not_same_dev, not_null_entry);
|
||||
DEBUG("%s: not_broadcast_entry=%u, dev_unregister=%u, ignore_route_ifdown=%u",
|
||||
__func__, not_broadcast_entry, dev_unregister, ignore_route_ifdown);
|
||||
nip_dbg("%s: don`t del route with %s down, ifindex=%u, not_same_dev=%u, not_null_entry=%u",
|
||||
__func__, dev->name, dev->ifindex, not_same_dev, not_null_entry);
|
||||
nip_dbg("%s: not_broadcast_entry=%u, dev_unregister=%u, ignore_route_ifdown=%u",
|
||||
__func__, not_broadcast_entry, dev_unregister, ignore_route_ifdown);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,16 +170,16 @@ void tcp_nip_close(struct sock *sk, long timeout)
|
||||
lock_sock(sk);
|
||||
sk->sk_shutdown = SHUTDOWN_MASK;
|
||||
|
||||
DEBUG("%s: sk_state:%d\n", __func__, sk->sk_state);
|
||||
nip_dbg("%s: sk_state:%d", __func__, sk->sk_state);
|
||||
|
||||
if (sk->sk_state == TCP_LISTEN) {
|
||||
tcp_set_state(sk, TCP_CLOSE);
|
||||
|
||||
sk_ack_backlog = READ_ONCE(sk->sk_ack_backlog);
|
||||
inet_csk_listen_stop(sk);
|
||||
DEBUG("%s: sk_state CLOSE, sk_ack_backlog=%u to %u, sk_max_ack_backlog=%u",
|
||||
__func__, sk_ack_backlog, READ_ONCE(sk->sk_ack_backlog),
|
||||
READ_ONCE(sk->sk_max_ack_backlog));
|
||||
nip_dbg("%s: sk_state CLOSE, sk_ack_backlog=%u to %u, sk_max_ack_backlog=%u",
|
||||
__func__, sk_ack_backlog, READ_ONCE(sk->sk_ack_backlog),
|
||||
READ_ONCE(sk->sk_max_ack_backlog));
|
||||
goto adjudge_to_death;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ void tcp_nip_close(struct sock *sk, long timeout)
|
||||
* TCP_SYN_RECV -> TCP_FIN_WAIT1 (forget it, it's impossible)
|
||||
* TCP_CLOSE_WAIT -> TCP_LAST_ACK
|
||||
*/
|
||||
DEBUG("%s: ready to send fin, sk_state:%d", __func__, sk->sk_state);
|
||||
nip_dbg("%s: ready to send fin, sk_state=%d", __func__, sk->sk_state);
|
||||
tcp_nip_send_fin(sk);
|
||||
}
|
||||
|
||||
@@ -326,11 +326,11 @@ static int tcp_nip_connect(struct sock *sk, struct sockaddr *uaddr,
|
||||
orig_dport = usin->sin_port;
|
||||
|
||||
/* Find the route and obtain the source address */
|
||||
DEBUG("%s, sk->sk_bound_dev_if is %d", __func__, sk->sk_bound_dev_if);
|
||||
nip_dbg("%s, sk->sk_bound_dev_if is %d", __func__, sk->sk_bound_dev_if);
|
||||
fln.flowin_oif = sk->sk_bound_dev_if;
|
||||
dst = nip_dst_lookup_flow(sock_net(sk), sk, &fln, NULL);
|
||||
if (IS_ERR(dst)) {
|
||||
DEBUG("%s cannot find dst", __func__);
|
||||
nip_dbg("%s cannot find dst", __func__);
|
||||
err = PTR_ERR(dst);
|
||||
goto failure;
|
||||
}
|
||||
@@ -341,13 +341,13 @@ static int tcp_nip_connect(struct sock *sk, struct sockaddr *uaddr,
|
||||
fln.saddr = sk->sk_nip_rcv_saddr;
|
||||
|
||||
if (nip_addr_invalid(&fln.daddr)) {
|
||||
DEBUG("%s: nip daddr invalid, bitlen=%u.", __func__, fln.daddr.bitlen);
|
||||
nip_dbg("%s: nip daddr invalid, bitlen=%u", __func__, fln.daddr.bitlen);
|
||||
err = -EFAULT;
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (nip_addr_invalid(&fln.saddr)) {
|
||||
DEBUG("%s: nip saddr invalid, bitlen=%u.", __func__, fln.saddr.bitlen);
|
||||
nip_dbg("%s: nip saddr invalid, bitlen=%u", __func__, fln.saddr.bitlen);
|
||||
err = -EFAULT;
|
||||
goto failure;
|
||||
}
|
||||
@@ -413,8 +413,7 @@ static void tcp_nip_send_reset(struct sock *sk, struct sk_buff *skb)
|
||||
if (th->rst)
|
||||
return;
|
||||
|
||||
DEBUG("%s: send RST!", __func__);
|
||||
|
||||
nip_dbg("%s: send RST", __func__);
|
||||
if (th->ack)
|
||||
seq = ntohl(th->ack_seq);
|
||||
else
|
||||
@@ -446,7 +445,7 @@ static int tcp_nip_send_synack(const struct sock *sk, struct dst_entry *dst,
|
||||
|
||||
skb = tcp_nip_make_synack(sk, dst, req, foc, synack_type);
|
||||
if (skb) {
|
||||
DEBUG("%s: TCP server create SYN+ACK skb successfully!", __func__);
|
||||
nip_dbg("%s: TCP server create SYN+ACK skb successfully", __func__);
|
||||
rcu_read_lock();
|
||||
err = nip_send_synack(req, skb);
|
||||
rcu_read_unlock();
|
||||
@@ -640,7 +639,7 @@ static int tcp_nip_keepalive_para_update(struct sock *sk,
|
||||
/* set keep idle (TCP_KEEPIDLE) */
|
||||
val = keepalive_time;
|
||||
if (val < 1 || val > MAX_NIP_TCP_KEEPIDLE) {
|
||||
DEBUG("%s keepalive_time(%u) invalid.", __func__, val);
|
||||
nip_dbg("%s keepalive_time(%u) invalid", __func__, val);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -659,7 +658,7 @@ static int tcp_nip_keepalive_para_update(struct sock *sk,
|
||||
/* set keep intvl (TCP_KEEPINTVL) */
|
||||
val = keepalive_intvl;
|
||||
if (val < 1 || val > MAX_NIP_TCP_KEEPINTVL) {
|
||||
DEBUG("%s keepalive_intvl(%u) invalid.", __func__, val);
|
||||
nip_dbg("%s keepalive_intvl(%u) invalid", __func__, val);
|
||||
return -EINVAL;
|
||||
}
|
||||
tp->keepalive_intvl = val;
|
||||
@@ -667,7 +666,7 @@ static int tcp_nip_keepalive_para_update(struct sock *sk,
|
||||
/* set keep cnt (TCP_KEEPCNT) */
|
||||
val = keepalive_probes;
|
||||
if (val < 1 || val > MAX_NIP_TCP_KEEPCNT) {
|
||||
DEBUG("%s keepalive_probes(%u) invalid.", __func__, val);
|
||||
nip_dbg("%s keepalive_probes(%u) invalid", __func__, val);
|
||||
return -EINVAL;
|
||||
}
|
||||
tp->keepalive_probes = val;
|
||||
@@ -677,7 +676,7 @@ static int tcp_nip_keepalive_para_update(struct sock *sk,
|
||||
sk->sk_prot->keepalive(sk, 1);
|
||||
sock_valbool_flag(sk, SOCK_KEEPOPEN, 1);
|
||||
} else {
|
||||
DEBUG("%s keepalive func is null.", __func__);
|
||||
nip_dbg("%s keepalive func is null", __func__);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -704,10 +703,10 @@ void tcp_nip_keepalive_enable(struct sock *sk)
|
||||
ntp->keepalive_probes_bak = tp->keepalive_probes;
|
||||
ntp->keepalive_intvl_bak = tp->keepalive_intvl;
|
||||
|
||||
DEBUG("%s HZ=%u, change time/probes/intvl [%u, %u, %u] to [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl, g_nip_keepalive_time, NIP_KEEPALIVE_PROBES,
|
||||
g_nip_keepalive_intvl);
|
||||
nip_dbg("%s HZ=%u, change time/probes/intvl [%u, %u, %u] to [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl, g_nip_keepalive_time, NIP_KEEPALIVE_PROBES,
|
||||
g_nip_keepalive_intvl);
|
||||
|
||||
tp->keepalive_time = g_nip_keepalive_time;
|
||||
tp->keepalive_probes = NIP_KEEPALIVE_PROBES;
|
||||
@@ -722,8 +721,8 @@ void tcp_nip_keepalive_enable(struct sock *sk)
|
||||
ntp->keepalive_time_bak = tp->keepalive_time;
|
||||
ntp->keepalive_probes_bak = tp->keepalive_probes;
|
||||
ntp->keepalive_intvl_bak = tp->keepalive_intvl;
|
||||
DEBUG("%s HZ=%u, backup normal time/probes/intvl [%u, %u, %u]", __func__,
|
||||
HZ, tp->keepalive_time, tp->keepalive_probes, tp->keepalive_intvl);
|
||||
nip_dbg("%s HZ=%u, backup normal time/probes/intvl [%u, %u, %u]", __func__,
|
||||
HZ, tp->keepalive_time, tp->keepalive_probes, tp->keepalive_intvl);
|
||||
}
|
||||
|
||||
/* change para to nip para */
|
||||
@@ -731,14 +730,14 @@ void tcp_nip_keepalive_enable(struct sock *sk)
|
||||
g_nip_keepalive_intvl,
|
||||
NIP_KEEPALIVE_PROBES);
|
||||
if (ret != 0) {
|
||||
DEBUG("%s fail, HZ=%u, time/probes/intvl [%u, %u, %u]", __func__,
|
||||
HZ, tp->keepalive_time, tp->keepalive_probes, tp->keepalive_intvl);
|
||||
nip_dbg("%s fail, HZ=%u, time/probes/intvl [%u, %u, %u]", __func__,
|
||||
HZ, tp->keepalive_time, tp->keepalive_probes, tp->keepalive_intvl);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG("%s ok, HZ=%u, time/probes/intvl [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl);
|
||||
nip_dbg("%s ok, HZ=%u, time/probes/intvl [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl);
|
||||
ntp->nip_keepalive_enable = true;
|
||||
#endif
|
||||
}
|
||||
@@ -754,7 +753,7 @@ void tcp_nip_keepalive_disable(struct sock *sk)
|
||||
|
||||
if (!sock_flag(sk, SOCK_KEEPOPEN)) {
|
||||
ntp->nip_keepalive_enable = false;
|
||||
DEBUG("%s ok, HZ=%u, normal ka has disable.", __func__, HZ);
|
||||
nip_dbg("%s ok, HZ=%u, normal ka has disable", __func__, HZ);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -763,10 +762,10 @@ void tcp_nip_keepalive_disable(struct sock *sk)
|
||||
|
||||
/* newip keepalive change to normal keepalive */
|
||||
if (ntp->keepalive_time_bak) {
|
||||
DEBUG("%s HZ=%u, change normal time/probes/intvl [%u, %u, %u] to [%u, %u, %u].",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl, ntp->keepalive_time_bak, ntp->keepalive_probes_bak,
|
||||
ntp->keepalive_intvl_bak);
|
||||
nip_dbg("%s HZ=%u, change normal time/probes/intvl [%u, %u, %u] to [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl, ntp->keepalive_time_bak, ntp->keepalive_probes_bak,
|
||||
ntp->keepalive_intvl_bak);
|
||||
tp->keepalive_time = ntp->keepalive_time_bak;
|
||||
tp->keepalive_probes = ntp->keepalive_probes_bak;
|
||||
tp->keepalive_intvl = ntp->keepalive_intvl_bak;
|
||||
@@ -783,7 +782,7 @@ void tcp_nip_keepalive_disable(struct sock *sk)
|
||||
sk->sk_prot->keepalive(sk, 0);
|
||||
sock_valbool_flag(sk, SOCK_KEEPOPEN, 0);
|
||||
|
||||
DEBUG("%s ok, HZ=%u, idle_ka_probes_out=%u", __func__, HZ, g_nip_idle_ka_probes_out);
|
||||
nip_dbg("%s ok, HZ=%u, idle_ka_probes_out=%u", __func__, HZ, g_nip_idle_ka_probes_out);
|
||||
ntp->nip_keepalive_enable = false;
|
||||
#endif
|
||||
}
|
||||
@@ -940,7 +939,7 @@ int tcp_nip_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
|
||||
restart:
|
||||
mss_now = tcp_nip_send_mss(sk, &size_goal, flags);
|
||||
|
||||
DEBUG("%s: mss_now=%d", __func__, mss_now);
|
||||
nip_dbg("%s: mss_now=%d", __func__, mss_now);
|
||||
|
||||
err = -EPIPE;
|
||||
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
|
||||
@@ -982,7 +981,7 @@ restart:
|
||||
if (err)
|
||||
goto do_fault;
|
||||
} else {
|
||||
DEBUG("%s: msg too big! tcp cannot devide packet now", __func__);
|
||||
nip_dbg("%s: msg too big, tcp cannot devide packet now", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1070,9 +1069,8 @@ void tcp_nip_cleanup_rbuf(struct sock *sk, int copied)
|
||||
((icsk->icsk_ack.pending & ICSK_ACK_PUSHED2) ||
|
||||
((icsk->icsk_ack.pending & ICSK_ACK_PUSHED) &&
|
||||
!inet_csk_in_pingpong_mode(sk))) &&
|
||||
!atomic_read(&sk->sk_rmem_alloc))) {
|
||||
!atomic_read(&sk->sk_rmem_alloc)))
|
||||
time_to_ack = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* We send an ACK if we can now advertise a non-zero window
|
||||
@@ -1209,7 +1207,7 @@ int tcp_nip_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonbloc
|
||||
release_sock(sk);
|
||||
lock_sock(sk);
|
||||
} else {
|
||||
DEBUG("%s: no enough data receive queue, wait", __func__);
|
||||
nip_dbg("%s: no enough data receive queue, wait", __func__);
|
||||
sk_wait_data(sk, &timeo, last);
|
||||
}
|
||||
continue;
|
||||
@@ -1217,11 +1215,11 @@ found_ok_skb:
|
||||
used = skb->len - offset;
|
||||
if (len_tmp < used)
|
||||
used = len_tmp;
|
||||
DEBUG("%s: copy data into msg, len=%ld", __func__, used);
|
||||
nip_dbg("%s: copy data into msg, len=%ld", __func__, used);
|
||||
if (!(flags & MSG_TRUNC)) {
|
||||
err = skb_copy_datagram_msg(skb, offset, msg, used);
|
||||
if (err) {
|
||||
DEBUG("%s: copy data failed!", __func__);
|
||||
nip_dbg("%s: copy data failed", __func__);
|
||||
if (!copied)
|
||||
copied = -EFAULT;
|
||||
break;
|
||||
@@ -1297,7 +1295,7 @@ void tcp_nip_destroy_sock(struct sock *sk)
|
||||
*/
|
||||
static int tcp_nip_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
DEBUG("%s: received newip tcp skb, sk_state=%d", __func__, sk->sk_state);
|
||||
nip_dbg("%s: received newip tcp skb, sk_state=%d", __func__, sk->sk_state);
|
||||
|
||||
if (sk->sk_state == TCP_ESTABLISHED) {
|
||||
struct dst_entry *dst = sk->sk_rx_dst;
|
||||
@@ -1315,7 +1313,7 @@ static int tcp_nip_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||
|
||||
/* The connection is established in cookie mode to defend against SYN-flood attacks */
|
||||
if (sk->sk_state == TCP_LISTEN)
|
||||
DEBUG("found TCP_LISTEN SOCK!!!");
|
||||
nip_dbg("found TCP_LISTEN SOCK");
|
||||
|
||||
if (tcp_nip_rcv_state_process(sk, skb))
|
||||
goto discard;
|
||||
@@ -1370,7 +1368,7 @@ static bool tcp_nip_add_backlog(struct sock *sk, struct sk_buff *skb)
|
||||
if (unlikely(sk_add_backlog(sk, skb, limit))) {
|
||||
bh_unlock_sock(sk);
|
||||
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP);
|
||||
DEBUG("%s: insert backlog fail.", __func__);
|
||||
nip_dbg("%s: insert backlog fail", __func__);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1391,40 +1389,40 @@ static int tcp_nip_rcv(struct sk_buff *skb)
|
||||
int dif = skb->skb_iif;
|
||||
|
||||
if (skb->pkt_type != PACKET_HOST) {
|
||||
DEBUG("%s unknown pkt-type(%u), drop skb.", __func__, skb->pkt_type);
|
||||
nip_dbg("%s unknown pkt-type(%u), drop skb", __func__, skb->pkt_type);
|
||||
goto discard_it;
|
||||
}
|
||||
|
||||
if (!nip_get_tcp_input_checksum(skb)) {
|
||||
DEBUG("%s checksum fail, drop skb.", __func__);
|
||||
nip_dbg("%s checksum fail, drop skb", __func__);
|
||||
goto discard_it;
|
||||
}
|
||||
|
||||
th = (const struct tcphdr *)skb->data;
|
||||
|
||||
if (unlikely(th->doff < sizeof(struct tcphdr) / TCP_NUM_4)) {
|
||||
DEBUG("%s non-four byte alignment, drop skb.", __func__);
|
||||
nip_dbg("%s non-four byte alignment, drop skb", __func__);
|
||||
goto discard_it;
|
||||
}
|
||||
|
||||
sk = __ninet_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th),
|
||||
th->source, th->dest, dif, &refcounted);
|
||||
if (!sk) {
|
||||
DEBUG("%s: can`t find related sock for skb, will disconnect.", __func__);
|
||||
nip_dbg("%s: can`t find related sock for skb, will disconnect", __func__);
|
||||
goto no_tcp_socket;
|
||||
}
|
||||
|
||||
if (sk->sk_state == TCP_TIME_WAIT) {
|
||||
/* Handles the SK portion of the interrupt state */
|
||||
DEBUG("%s sk_state is TCP_TIME_WAIT, drop skb.", __func__);
|
||||
nip_dbg("%s sk_state is TCP_TIME_WAIT, drop skb", __func__);
|
||||
goto discard_it;
|
||||
}
|
||||
if (sk->sk_state == TCP_NEW_SYN_RECV) {
|
||||
struct request_sock *req = inet_reqsk(sk);
|
||||
struct sock *nsk;
|
||||
|
||||
DEBUG("%s: TCP server into third shake hands! sk->sk_state:%d",
|
||||
__func__, sk->sk_state);
|
||||
nip_dbg("%s: TCP server into third shake hands, sk->sk_state:%d",
|
||||
__func__, sk->sk_state);
|
||||
sk = req->rsk_listener;
|
||||
|
||||
sock_hold(sk);
|
||||
@@ -1439,12 +1437,12 @@ static int tcp_nip_rcv(struct sk_buff *skb)
|
||||
nsk = tcp_nip_check_req(sk, skb, req);
|
||||
}
|
||||
if (!nsk || nsk == sk) {
|
||||
DEBUG("%s skb info error and create newsk failure, drop skb.", __func__);
|
||||
nip_dbg("%s skb info error and create newsk failure, drop skb", __func__);
|
||||
reqsk_put(req);
|
||||
goto discard_and_relse;
|
||||
}
|
||||
if (tcp_nip_child_process(sk, nsk, skb)) {
|
||||
DEBUG("%s child process fail, drop skb.", __func__);
|
||||
nip_dbg("%s child process fail, drop skb", __func__);
|
||||
goto discard_and_relse;
|
||||
} else {
|
||||
sock_put(sk);
|
||||
@@ -1455,15 +1453,15 @@ static int tcp_nip_rcv(struct sk_buff *skb)
|
||||
tcp_nip_fill_cb(skb, th);
|
||||
|
||||
if (tcp_filter(sk, skb)) {
|
||||
DEBUG("%s tcp filter fail, drop skb.", __func__);
|
||||
nip_dbg("%s tcp filter fail, drop skb", __func__);
|
||||
goto discard_and_relse;
|
||||
}
|
||||
th = (const struct tcphdr *)skb->data;
|
||||
skb->dev = NULL;
|
||||
|
||||
if (sk->sk_state == TCP_LISTEN) {
|
||||
DEBUG("%s: TCP server into first shake hands! sk->sk_state:%d",
|
||||
__func__, sk->sk_state);
|
||||
nip_dbg("%s: TCP server into first shake hands! sk->sk_state:%d",
|
||||
__func__, sk->sk_state);
|
||||
ret = tcp_nip_do_rcv(sk, skb);
|
||||
goto put_and_return;
|
||||
}
|
||||
@@ -1473,10 +1471,9 @@ static int tcp_nip_rcv(struct sk_buff *skb)
|
||||
if (!sock_owned_by_user(sk)) {
|
||||
ret = tcp_nip_do_rcv(sk, skb);
|
||||
} else {
|
||||
DEBUG("%s: sock locked by user! put packet into backlog",
|
||||
__func__);
|
||||
nip_dbg("%s: sock locked by user, put packet into backlog", __func__);
|
||||
if (tcp_nip_add_backlog(sk, skb)) {
|
||||
DEBUG("%s add backlog fail, drop skb.", __func__);
|
||||
nip_dbg("%s add backlog fail, drop skb", __func__);
|
||||
goto discard_and_relse;
|
||||
}
|
||||
}
|
||||
@@ -1529,7 +1526,7 @@ static void tcp_nip_early_demux(struct sk_buff *skb)
|
||||
if (dst)
|
||||
dst = dst_check(dst, 0);
|
||||
if (dst && inet_sk(sk)->rx_dst_ifindex == skb->skb_iif) {
|
||||
DEBUG("%s: find sock in ehash, set dst for skb", __func__);
|
||||
nip_dbg("%s: find sock in ehash, set dst for skb", __func__);
|
||||
skb_dst_set_noref(skb, dst);
|
||||
}
|
||||
}
|
||||
@@ -1569,7 +1566,7 @@ void tcp_nip_done(struct sock *sk)
|
||||
this_cpu_dec(*sk->sk_prot->orphan_count);
|
||||
local_bh_enable();
|
||||
sock_put(sk);
|
||||
DEBUG("%s: close sock done!!", __func__);
|
||||
nip_dbg("%s: close sock done", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1594,11 +1591,10 @@ int tcp_nip_disconnect(struct sock *sk, int flags)
|
||||
if (old_state == TCP_LISTEN) {
|
||||
sk_ack_backlog = READ_ONCE(sk->sk_ack_backlog);
|
||||
inet_csk_listen_stop(sk);
|
||||
DEBUG("%s: sk_state CLOSE, sk_ack_backlog=%u to %u, sk_max_ack_backlog=%u",
|
||||
__func__, sk_ack_backlog, READ_ONCE(sk->sk_ack_backlog),
|
||||
READ_ONCE(sk->sk_max_ack_backlog));
|
||||
} else if (tcp_nip_need_reset(old_state) ||
|
||||
(tp->snd_nxt != tp->write_seq &&
|
||||
nip_dbg("%s: sk_state CLOSE, sk_ack_backlog=%u to %u, sk_max_ack_backlog=%u",
|
||||
__func__, sk_ack_backlog, READ_ONCE(sk->sk_ack_backlog),
|
||||
READ_ONCE(sk->sk_max_ack_backlog));
|
||||
} else if (tcp_nip_need_reset(old_state) || (tp->snd_nxt != tp->write_seq &&
|
||||
(1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK))) {
|
||||
tcp_nip_send_active_reset(sk, gfp_any());
|
||||
sk->sk_err = ECONNRESET;
|
||||
@@ -1662,8 +1658,8 @@ struct sock *ninet_csk_accept(struct sock *sk, int flags, int *err, bool kern)
|
||||
u32 sk_max_ack_backlog = READ_ONCE(sk->sk_max_ack_backlog);
|
||||
|
||||
newsk = inet_csk_accept(sk, flags, err, kern);
|
||||
DEBUG("%s: accept %s, sk_ack_backlog_last=%u, sk_max_ack_backlog=%u",
|
||||
__func__, (newsk ? "ok" : "fail"), sk_ack_backlog_last, sk_max_ack_backlog);
|
||||
nip_dbg("%s: accept %s, sk_ack_backlog_last=%u, sk_max_ack_backlog=%u",
|
||||
__func__, (newsk ? "ok" : "fail"), sk_ack_backlog_last, sk_max_ack_backlog);
|
||||
|
||||
return newsk;
|
||||
}
|
||||
@@ -1751,7 +1747,7 @@ void nip_dbg(const char *fmt, ...)
|
||||
{
|
||||
char str[LOG_PRINT_MAX_LEN];
|
||||
va_list args;
|
||||
s32 ret;
|
||||
int len = 0;
|
||||
|
||||
if (!g_nip_debug)
|
||||
return;
|
||||
@@ -1759,10 +1755,11 @@ void nip_dbg(const char *fmt, ...)
|
||||
memset(str, 0, sizeof(str));
|
||||
(void)memset(&args, 0, sizeof(va_list));
|
||||
va_start(args, fmt);
|
||||
ret = vsnprintf(str, sizeof(str), fmt, args) + 1;
|
||||
len += vsnprintf(str + len, LOG_PRINT_MAX_LEN - len, fmt, args);
|
||||
va_end(args);
|
||||
if (ret < 0 || ret > sizeof(str)) {
|
||||
if (len < 0 || len > LOG_PRINT_MAX_LEN) {
|
||||
pr_crit("nip log len error");
|
||||
printk_once(KERN_ERR "please increase LOG_PRINT_MAX_LEN");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ void tcp_nip_fin(struct sock *sk)
|
||||
/* Only TCP_LISTEN and TCP_CLOSE are left, in these
|
||||
* cases we should never reach this piece of code.
|
||||
*/
|
||||
DEBUG("%s: Impossible, sk->sk_state=%d", __func__, sk->sk_state);
|
||||
nip_dbg("%s: Impossible, sk->sk_state=%d", __func__, sk->sk_state);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -220,30 +220,30 @@ static void tcp_nip_data_queue(struct sock *sk, struct sk_buff *skb)
|
||||
tp->snd_up = tp->snd_up > PKT_DISCARD_MAX ? 0 : tp->snd_up;
|
||||
|
||||
if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) {
|
||||
DEBUG("%s: no data, only handle ack.", __func__);
|
||||
nip_dbg("%s: no data, only handle ack", __func__);
|
||||
__kfree_skb(skb);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TCP_SKB_CB(skb)->seq == tp->rcv_nxt) {
|
||||
if (cur_win == 0) {
|
||||
DEBUG("%s: rcv window is 0.", __func__);
|
||||
nip_dbg("%s: rcv window is 0", __func__);
|
||||
goto out_of_window;
|
||||
}
|
||||
}
|
||||
|
||||
/* Out of window. F.e. zero window probe. */
|
||||
if (!before(TCP_SKB_CB(skb)->seq, seq_max)) {
|
||||
DEBUG("%s: out of rcv win, seq=[%u-%u], rcv_nxt=%u, seq_max=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_nxt, seq_max);
|
||||
nip_dbg("%s: out of rcv win, seq=[%u-%u], rcv_nxt=%u, seq_max=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_nxt, seq_max);
|
||||
goto out_of_window;
|
||||
}
|
||||
|
||||
if (!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) {
|
||||
/* A retransmit, 2nd most common case. Force an immediate ack. */
|
||||
DEBUG("%s: rcv retransmit pkt, seq=[%u-%u], rcv_nxt=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);
|
||||
nip_dbg("%s: rcv retransmit pkt, seq=[%u-%u], rcv_nxt=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);
|
||||
out_of_window:
|
||||
inet_csk_schedule_ack(sk);
|
||||
tcp_drop(sk, skb);
|
||||
@@ -253,9 +253,9 @@ out_of_window:
|
||||
__skb_pull(skb, tcp_hdr(skb)->doff * TCP_NUM_4);
|
||||
|
||||
if (cur_win == 0 || after(TCP_SKB_CB(skb)->end_seq, seq_max)) {
|
||||
DEBUG("%s: win lack, drop pkt, seq=[%u-%u], seq_max=%u, rmem_alloc/rcvbuf=[%u:%u]",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
seq_max, atomic_read(&sk->sk_rmem_alloc), sk->sk_rcvbuf);
|
||||
nip_dbg("%s: win lack, drop pkt, seq=[%u-%u], seq_max=%u, rmem_alloc/rbuf=[%u:%u]",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
seq_max, atomic_read(&sk->sk_rmem_alloc), sk->sk_rcvbuf);
|
||||
/* wake up processes that are blocked for lack of data */
|
||||
sk->sk_data_ready(sk);
|
||||
inet_csk_schedule_ack(sk);
|
||||
@@ -272,9 +272,9 @@ out_of_window:
|
||||
if (TCP_SKB_CB(skb)->seq != tp->rcv_nxt)
|
||||
tcp_nip_overlap_handle(tp, skb);
|
||||
|
||||
DEBUG("%s: newip packet received. seq=[%u-%u], rcv_nxt=%u, skb->len=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_nxt, skb->len);
|
||||
nip_dbg("%s: newip packet received. seq=[%u-%u], rcv_nxt=%u, skb->len=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_nxt, skb->len);
|
||||
|
||||
__skb_queue_tail(&sk->sk_receive_queue, skb);
|
||||
skb_set_owner_r(skb, sk);
|
||||
@@ -289,9 +289,9 @@ out_of_window:
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG("%s: newip ofo packet received. seq=[%u-%u], rcv_nxt=%u, skb->len=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_nxt, skb->len);
|
||||
nip_dbg("%s: newip ofo packet received. seq=[%u-%u], rcv_nxt=%u, skb->len=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_nxt, skb->len);
|
||||
|
||||
tcp_nip_data_queue_ofo(sk, skb);
|
||||
}
|
||||
@@ -342,7 +342,7 @@ void tcp_nip_send_delayed_ack(struct sock *sk)
|
||||
if (icsk->icsk_ack.pending & ICSK_ACK_TIMER) {
|
||||
if (time_before_eq(icsk->icsk_ack.timeout,
|
||||
jiffies + (ato >> TCP_NIP_4BYTE_PAYLOAD))) {
|
||||
DEBUG("%s: ok", __func__);
|
||||
nip_dbg("%s: ok", __func__);
|
||||
tcp_nip_send_ack(sk);
|
||||
return;
|
||||
}
|
||||
@@ -392,7 +392,7 @@ static inline void tcp_nip_ack_snd_check(struct sock *sk)
|
||||
{
|
||||
if (!inet_csk_ack_scheduled(sk)) {
|
||||
/* We sent a data segment already. */
|
||||
DEBUG("We sent a data segment already.");
|
||||
nip_dbg("We sent a data segment already");
|
||||
return;
|
||||
}
|
||||
__tcp_nip_ack_snd_check(sk, 1);
|
||||
@@ -434,7 +434,7 @@ static int tcp_nip_clean_rtx_queue(struct sock *sk, ktime_t *skb_snd_tstamp)
|
||||
if (after(scb->end_seq, tp->snd_una)) {
|
||||
if (tcp_skb_pcount(skb) == 1 || !after(tp->snd_una, scb->seq))
|
||||
break;
|
||||
DEBUG("%s: ack error!", __func__);
|
||||
nip_dbg("%s: ack error", __func__);
|
||||
} else {
|
||||
prefetchw(skb->next);
|
||||
acked_pcount = tcp_skb_pcount(skb);
|
||||
@@ -507,7 +507,7 @@ void tcp_nip_parse_mss(struct tcp_options_received *opt_rx,
|
||||
if (opsize == TCPOLEN_MSS && th->syn && !estab) {
|
||||
u16 in_mss = get_unaligned_be16(ptr);
|
||||
|
||||
DEBUG("%s: in_mss %d", __func__, in_mss);
|
||||
nip_dbg("%s: in_mss %d", __func__, in_mss);
|
||||
|
||||
if (in_mss) {
|
||||
if (opt_rx->user_mss &&
|
||||
@@ -746,7 +746,6 @@ void tcp_nip_openreq_init_rwin(struct request_sock *req,
|
||||
int mss;
|
||||
u32 window_clamp;
|
||||
__u8 rcv_wscale;
|
||||
int sysctl_tcp_nip_window_scaling = 0;
|
||||
|
||||
mss = tcp_mss_clamp(tp, dst_metric_advmss(dst));
|
||||
|
||||
@@ -764,7 +763,7 @@ void tcp_nip_openreq_init_rwin(struct request_sock *req,
|
||||
mss - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0),
|
||||
&req->rsk_rcv_wnd,
|
||||
&req->rsk_window_clamp,
|
||||
sysctl_tcp_nip_window_scaling,
|
||||
0,
|
||||
&rcv_wscale,
|
||||
0);
|
||||
ireq->rcv_wscale = g_wscale_enable == 1 ? g_wscale : rcv_wscale;
|
||||
@@ -795,7 +794,7 @@ int _tcp_nip_conn_request(struct request_sock_ops *rsk_ops,
|
||||
* the current request is discarded
|
||||
*/
|
||||
if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
|
||||
DEBUG("inet_csk_reqsk_queue_is_full!!!!!");
|
||||
nip_dbg("inet_csk_reqsk_queue_is_full");
|
||||
goto drop;
|
||||
}
|
||||
|
||||
@@ -805,8 +804,9 @@ int _tcp_nip_conn_request(struct request_sock_ops *rsk_ops,
|
||||
*/
|
||||
if (sk_acceptq_is_full(sk)) {
|
||||
NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
|
||||
DEBUG("%s sk_acceptq_is_full, sk_ack_backlog=%u, sk_max_ack_backlog=%u",
|
||||
__func__, READ_ONCE(sk->sk_ack_backlog), READ_ONCE(sk->sk_max_ack_backlog));
|
||||
nip_dbg("%s sk_acceptq_is_full, sk_ack_backlog=%u, sk_max_ack_backlog=%u",
|
||||
__func__, READ_ONCE(sk->sk_ack_backlog),
|
||||
READ_ONCE(sk->sk_max_ack_backlog));
|
||||
goto drop;
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ static void tcp_nip_ack_update_window(struct sock *sk, const struct sk_buff *skb
|
||||
tcp_update_wl(tp, ack_seq);
|
||||
|
||||
if (tp->snd_wnd != nwin) {
|
||||
DEBUG("%s snd_wnd change [%u to %u]", __func__, tp->snd_wnd, nwin);
|
||||
nip_dbg("%s snd_wnd change [%u to %u]", __func__, tp->snd_wnd, nwin);
|
||||
tp->snd_wnd = nwin;
|
||||
tp->pred_flags = 0;
|
||||
}
|
||||
@@ -922,7 +922,7 @@ static void tcp_nip_ack_probe(struct sock *sk)
|
||||
|
||||
if (!after(TCP_SKB_CB(tcp_nip_send_head(sk))->end_seq, tcp_wnd_end(tp))) {
|
||||
icsk->icsk_backoff = 0;
|
||||
DEBUG("%s stop probe0 timer.", __func__);
|
||||
nip_dbg("%s stop probe0 timer", __func__);
|
||||
inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0);
|
||||
/* Socket must be waked up by subsequent tcp_data_snd_check().
|
||||
* This function is not for random using!
|
||||
@@ -932,8 +932,8 @@ static void tcp_nip_ack_probe(struct sock *sk)
|
||||
unsigned long base_when = tcp_probe0_base(sk);
|
||||
u8 icsk_backoff = inet_csk(sk)->icsk_backoff;
|
||||
|
||||
DEBUG("%s start probe0 timer, when=%u, RTO MAX=%u, base_when=%u, icsk_backoff=%u",
|
||||
__func__, when, TCP_RTO_MAX, base_when, icsk_backoff);
|
||||
nip_dbg("%s start probe0 timer, when=%u, RTO MAX=%u, base_when=%u, backoff=%u",
|
||||
__func__, when, TCP_RTO_MAX, base_when, icsk_backoff);
|
||||
inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, TCP_RTO_MAX);
|
||||
}
|
||||
}
|
||||
@@ -952,7 +952,7 @@ static void tcp_nip_ack_retrans(struct sock *sk, u32 ack, int ack_type, u32 retr
|
||||
|
||||
skb_queue_walk_safe(&sk->sk_write_queue, skb, tmp) {
|
||||
if (skb == tcp_nip_send_head(sk)) {
|
||||
SSTHRESH_DBG("%s %s ack retrans(%u) end, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
ssthresh_dbg("%s %s ack retrans(%u) end, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ack_str[index], ntp->ack_retrans_num, ack,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out);
|
||||
@@ -964,7 +964,7 @@ static void tcp_nip_ack_retrans(struct sock *sk, u32 ack, int ack_type, u32 retr
|
||||
}
|
||||
|
||||
if (TCP_SKB_CB(skb)->seq > tp->selective_acks[0].end_seq) {
|
||||
SSTHRESH_DBG("%s %s ack retrans(%u) finish, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
ssthresh_dbg("%s %s ack retrans(%u) finish, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ack_str[index], ntp->ack_retrans_num, ack,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out);
|
||||
@@ -985,7 +985,7 @@ static void tcp_nip_ack_retrans(struct sock *sk, u32 ack, int ack_type, u32 retr
|
||||
ntp->ack_retrans_num++;
|
||||
ntp->ack_retrans_seq = TCP_SKB_CB(skb)->end_seq;
|
||||
} else {
|
||||
RETRANS_DBG("%s %s ack retrans(%u) no end, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
retrans_dbg("%s %s ack retrans(%u) no end, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ack_str[index], ntp->ack_retrans_num, ack,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out);
|
||||
@@ -1015,7 +1015,7 @@ static void tcp_nip_dup_ack_retrans(struct sock *sk, const struct sk_buff *skb,
|
||||
u32 last_nip_ssthresh = ntp->nip_ssthresh;
|
||||
|
||||
if (tp->selective_acks[0].end_seq)
|
||||
SSTHRESH_DBG("%s last retans(%u) not end, seq=%u~%u, pkt_out=%u",
|
||||
ssthresh_dbg("%s last retans(%u) not end, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ntp->ack_retrans_num,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq,
|
||||
@@ -1027,7 +1027,7 @@ static void tcp_nip_dup_ack_retrans(struct sock *sk, const struct sk_buff *skb,
|
||||
ntp->ack_retrans_num = 0;
|
||||
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
SSTHRESH_DBG("%s new dup ack, win %u to %u, discard_num=%u, seq=%u~%u",
|
||||
ssthresh_dbg("%s new dup ack, win %u to %u, discard_num=%u, seq=%u~%u",
|
||||
__func__, last_nip_ssthresh, ntp->nip_ssthresh, discard_num,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq);
|
||||
@@ -1044,7 +1044,7 @@ static void tcp_nip_nor_ack_retrans(struct sock *sk, u32 ack, u32 retrans_num)
|
||||
|
||||
if (tp->selective_acks[0].end_seq != 0) {
|
||||
if (ack >= tp->selective_acks[0].end_seq) {
|
||||
SSTHRESH_DBG("%s nor ack retrans(%u) resume, seq=%u~%u, pkt_out=%u, ack=%u",
|
||||
ssthresh_dbg("%s nor ack retrans(%u) resume, seq=%u~%u, pkt_out=%u, ack=%u",
|
||||
__func__, ntp->ack_retrans_num,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out, ack);
|
||||
@@ -1073,7 +1073,7 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
u32 nip_ssthresh;
|
||||
|
||||
if (ntp->nip_ssthresh_reset != ack_reset) {
|
||||
SSTHRESH_DBG("%s ack reset win %u to %u, ack=%u",
|
||||
ssthresh_dbg("%s ack reset win %u to %u, ack=%u",
|
||||
__func__, ntp->nip_ssthresh, g_ssthresh_low, ack);
|
||||
ntp->nip_ssthresh_reset = ack_reset;
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
@@ -1082,20 +1082,20 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
u32 rtt_tstamp = tp->rcv_tstamp - skb_snd_tstamp;
|
||||
|
||||
if (rtt_tstamp >= g_rtt_tstamp_rto_up) {
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, rto %u to %u, ack=%u",
|
||||
ssthresh_dbg("%s rtt %u >= %u, win %u to %u, rto %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_rto_up,
|
||||
ntp->nip_ssthresh, g_ssthresh_low_min,
|
||||
icsk_rto_last, icsk->icsk_rto, ack);
|
||||
|
||||
ntp->nip_ssthresh = g_ssthresh_low_min;
|
||||
} else if (rtt_tstamp >= g_rtt_tstamp_high) {
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
ssthresh_dbg("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_high,
|
||||
ntp->nip_ssthresh, g_ssthresh_low, ack);
|
||||
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
} else if (rtt_tstamp >= g_rtt_tstamp_mid_high) {
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
ssthresh_dbg("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_mid_high,
|
||||
ntp->nip_ssthresh, g_ssthresh_mid_low, ack);
|
||||
|
||||
@@ -1112,7 +1112,7 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
nip_ssthresh = (ntp->nip_ssthresh * g_ssthresh_high_step +
|
||||
nip_ssthresh) / (g_ssthresh_high_step + 1);
|
||||
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
ssthresh_dbg("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_mid_low,
|
||||
ntp->nip_ssthresh, nip_ssthresh, ack);
|
||||
|
||||
@@ -1121,7 +1121,7 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
nip_ssthresh = (ntp->nip_ssthresh * g_ssthresh_high_step +
|
||||
g_ssthresh_high) / (g_ssthresh_high_step + 1);
|
||||
|
||||
SSTHRESH_DBG("%s rtt %u < %u, win %u to %u, ack=%u",
|
||||
ssthresh_dbg("%s rtt %u < %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_mid_low,
|
||||
ntp->nip_ssthresh, nip_ssthresh, ack);
|
||||
|
||||
@@ -1154,8 +1154,8 @@ static int tcp_nip_ack(struct sock *sk, const struct sk_buff *skb)
|
||||
|
||||
/* maybe zero window probe */
|
||||
if (!prior_packets) {
|
||||
DEBUG("%s: no unack pkt, seq=[%u-%u], rcv_nxt=%u, ack=%u",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt, ack);
|
||||
nip_dbg("%s: no unack pkt, seq=[%u-%u], rcv_nxt=%u, ack=%u", __func__,
|
||||
TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt, ack);
|
||||
if (tcp_nip_send_head(sk))
|
||||
tcp_nip_ack_probe(sk);
|
||||
return 1;
|
||||
@@ -1195,7 +1195,7 @@ static inline bool tcp_nip_sequence(const struct tcp_sock *tp, u32 seq, u32 end_
|
||||
/* When we get a reset we do this. */
|
||||
void tcp_nip_reset(struct sock *sk)
|
||||
{
|
||||
DEBUG("%s: handle RST!", __func__);
|
||||
nip_dbg("%s: handle RST", __func__);
|
||||
|
||||
/* We want the right error as BSD sees it (and indeed as we do). */
|
||||
switch (sk->sk_state) {
|
||||
@@ -1228,10 +1228,10 @@ static void tcp_nip_send_dupack(struct sock *sk, const struct sk_buff *skb)
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
|
||||
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
|
||||
before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
|
||||
before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt))
|
||||
NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKLOST);
|
||||
}
|
||||
DEBUG("%s send dup ack.", __func__);
|
||||
|
||||
nip_dbg("%s send dup ack", __func__);
|
||||
tcp_nip_send_ack(sk);
|
||||
}
|
||||
|
||||
@@ -1259,9 +1259,9 @@ static bool tcp_nip_validate_incoming(struct sock *sk, struct sk_buff *skb,
|
||||
* 02.Enter this branch when the receive window is 0
|
||||
*/
|
||||
if (!tcp_nip_sequence(tp, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq)) {
|
||||
DEBUG("%s receive unexpected pkt, drop it. seq=[%u-%u], rec_win=[%u-%u]",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_wup, tp->rcv_nxt + tcp_receive_window(tp));
|
||||
nip_dbg("%s receive unexpected pkt, drop it. seq=[%u-%u], rec_win=[%u-%u]",
|
||||
__func__, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
|
||||
tp->rcv_wup, tp->rcv_nxt + tcp_receive_window(tp));
|
||||
if (!th->rst)
|
||||
tcp_nip_send_dupack(sk, skb);
|
||||
else if (tcp_nip_reset_check(sk, skb))
|
||||
@@ -1538,7 +1538,7 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
}
|
||||
goto discard;
|
||||
case TCP_SYN_SENT:
|
||||
DEBUG("%s TCP_SYN_SENT!!", __func__);
|
||||
nip_dbg("%s TCP_SYN_SENT", __func__);
|
||||
tp->rx_opt.saw_tstamp = 0;
|
||||
tcp_mstamp_refresh(tp);
|
||||
queued = tcp_nip_rcv_synsent_state_process(sk, skb, th);
|
||||
@@ -1557,7 +1557,6 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
return 0;
|
||||
|
||||
acceptable = tcp_nip_ack(sk, skb);
|
||||
|
||||
/* If the third handshake ACK is invalid, 1 is returned
|
||||
* and the SKB is discarded in tcp_nip_rcv
|
||||
*/
|
||||
@@ -1574,7 +1573,7 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
/* Invoke memory barrier (annotated prior to checkpatch requirements) */
|
||||
smp_mb();
|
||||
tcp_set_state(sk, TCP_ESTABLISHED);
|
||||
DEBUG("TCP_ESTABLISHED!!!!!");
|
||||
nip_dbg("TCP_ESTABLISHED");
|
||||
sk->sk_state_change(sk);
|
||||
|
||||
/* Sets the part to be sent, and the size of the send window */
|
||||
@@ -1588,7 +1587,7 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
break;
|
||||
case TCP_FIN_WAIT1: {
|
||||
if (tp->snd_una != tp->write_seq) {
|
||||
DEBUG("%s: tp->snd_una != tp->write_seq!!", __func__);
|
||||
nip_dbg("%s: tp->snd_una != tp->write_seq", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1598,12 +1597,12 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
|
||||
after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {
|
||||
tcp_nip_done(sk);
|
||||
DEBUG("%s: received payload packets, call tcp_nip_done.", __func__);
|
||||
nip_dbg("%s: received payload packets, call tcp_nip_done", __func__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG("%s: TCP_FIN_WAIT1: recvd ack for fin.Wait for fin from other side.",
|
||||
__func__);
|
||||
nip_dbg("%s: TCP_FIN_WAIT1: recvd ack for fin.Wait for fin from other side",
|
||||
__func__);
|
||||
inet_csk_reset_keepalive_timer(sk, TCP_NIP_CSK_KEEPALIVE_CYCLE * HZ);
|
||||
|
||||
break;
|
||||
@@ -1611,15 +1610,15 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
|
||||
case TCP_CLOSING:
|
||||
if (tp->snd_una == tp->write_seq) {
|
||||
DEBUG("%s: TCP_CLOSING: recvd ack for fin.Ready to destroy.", __func__);
|
||||
nip_dbg("%s: TCP_CLOSING: recvd ack for fin.Ready to destroy", __func__);
|
||||
inet_csk_reset_keepalive_timer(sk, TCP_TIMEWAIT_LEN);
|
||||
goto discard;
|
||||
}
|
||||
break;
|
||||
case TCP_LAST_ACK:
|
||||
DEBUG("tcp_nip_rcv_state_process_2: TCP_LAST_ACK");
|
||||
nip_dbg("tcp_nip_rcv_state_process_2: TCP_LAST_ACK");
|
||||
if (tp->snd_una == tp->write_seq) {
|
||||
DEBUG("%s: LAST_ACK: recvd ack for fin.Directly destroy.", __func__);
|
||||
nip_dbg("%s: LAST_ACK: recvd ack for fin.Directly destroy", __func__);
|
||||
tcp_nip_done(sk);
|
||||
goto discard;
|
||||
}
|
||||
@@ -1628,16 +1627,17 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
|
||||
switch (sk->sk_state) {
|
||||
case TCP_CLOSE_WAIT:
|
||||
DEBUG("%s: into TCP_CLOSE_WAIT, rst = %d, seq = %u, end_seq = %u, rcv_nxt = %u",
|
||||
__func__, th->rst, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt);
|
||||
nip_dbg("%s: into TCP_CLOSE_WAIT, rst = %d, seq = %u, end_seq = %u, rcv_nxt = %u",
|
||||
__func__, th->rst, TCP_SKB_CB(skb)->seq,
|
||||
TCP_SKB_CB(skb)->seq, tp->rcv_nxt);
|
||||
fallthrough;
|
||||
case TCP_CLOSING:
|
||||
case TCP_LAST_ACK:
|
||||
if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
|
||||
DEBUG("%s: break in TCP_LAST_ACK", __func__);
|
||||
nip_dbg("%s: break in TCP_LAST_ACK", __func__);
|
||||
break;
|
||||
}
|
||||
DEBUG("tcp_nip_rcv_state_process_3: TCP_LAST_ACK_2");
|
||||
nip_dbg("tcp_nip_rcv_state_process_3: TCP_LAST_ACK_2");
|
||||
fallthrough;
|
||||
case TCP_FIN_WAIT1:
|
||||
case TCP_FIN_WAIT2:
|
||||
@@ -1648,7 +1648,7 @@ int tcp_nip_rcv_state_process(struct sock *sk, struct sk_buff *skb)
|
||||
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
|
||||
after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {
|
||||
tcp_nip_reset(sk);
|
||||
DEBUG("%s: call tcp_nip_reset", __func__);
|
||||
nip_dbg("%s: call tcp_nip_reset", __func__);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1712,10 +1712,9 @@ struct sock *tcp_nip_check_req(struct sock *sk, struct sk_buff *skb,
|
||||
|
||||
tmp_opt.saw_tstamp = 0;
|
||||
/* Check whether the TCP option exists */
|
||||
if (th->doff > (sizeof(struct tcphdr) >> TCP_NIP_4BYTE_PAYLOAD)) {
|
||||
if (th->doff > (sizeof(struct tcphdr) >> TCP_NIP_4BYTE_PAYLOAD))
|
||||
/* Parsing TCP options */
|
||||
tcp_nip_parse_options(skb, &tmp_opt, 0, NULL);
|
||||
}
|
||||
|
||||
/* ACK but the serial number does not match,
|
||||
* return to the original control block, no processing outside
|
||||
@@ -1723,13 +1722,13 @@ struct sock *tcp_nip_check_req(struct sock *sk, struct sk_buff *skb,
|
||||
if ((flg & TCP_FLAG_ACK) &&
|
||||
(TCP_SKB_CB(skb)->ack_seq !=
|
||||
tcp_rsk(req)->snt_isn + 1)) {
|
||||
DEBUG("%s ack_seq is wrong!", __func__);
|
||||
nip_dbg("%s ack_seq is wrong", __func__);
|
||||
return sk;
|
||||
}
|
||||
|
||||
/* The above process guarantees that there is an ACK, if not, return directly */
|
||||
if (!(flg & TCP_FLAG_ACK)) {
|
||||
DEBUG("%s No TCP_FLAG_ACK !!!!", __func__);
|
||||
nip_dbg("%s No TCP_FLAG_ACK", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1739,10 +1738,10 @@ struct sock *tcp_nip_check_req(struct sock *sk, struct sk_buff *skb,
|
||||
child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL,
|
||||
req, &own_req);
|
||||
if (!child) {
|
||||
DEBUG("%s No listen_overflow!!!!", __func__);
|
||||
nip_dbg("%s No listen_overflow", __func__);
|
||||
goto listen_overflow;
|
||||
}
|
||||
DEBUG("%s creat child sock successfully!", __func__);
|
||||
nip_dbg("%s creat child sock successfully", __func__);
|
||||
|
||||
sock_rps_save_rxhash(child, skb);
|
||||
/* Calculate the time spent synack-ack in three handshakes */
|
||||
|
||||
@@ -103,9 +103,8 @@ static void tcp_nip_event_new_data_sent(struct sock *sk, struct sk_buff *skb)
|
||||
tp->snd_nxt = TCP_SKB_CB(skb)->end_seq;
|
||||
tp->packets_out += tcp_skb_pcount(skb);
|
||||
if (!prior_packets || icsk->icsk_pending == ICSK_TIME_EARLY_RETRANS ||
|
||||
icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
|
||||
icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)
|
||||
tcp_nip_rearm_rto(sk);
|
||||
}
|
||||
}
|
||||
|
||||
void __tcp_nip_push_pending_frames(struct sock *sk, unsigned int cur_mss,
|
||||
@@ -141,8 +140,8 @@ u32 __nip_tcp_select_window(struct sock *sk)
|
||||
|
||||
free_space = round_down(free_space, 1 << tp->rx_opt.rcv_wscale);
|
||||
if (free_space < (allowed_space >> TCP_NUM_4) || free_space < mss) {
|
||||
DEBUG("%s rcv_wnd is 0, [allowed|full|free]space=[%u, %u, %u], mss=%u",
|
||||
__func__, allowed_space, full_space, free_space, mss);
|
||||
nip_dbg("%s rcv_wnd is 0, [allowed|full|free]space=[%u, %u, %u], mss=%u",
|
||||
__func__, allowed_space, full_space, free_space, mss);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -168,9 +167,9 @@ u32 __nip_tcp_select_window(struct sock *sk)
|
||||
* 1<<rcv_wscale > mss.
|
||||
*/
|
||||
window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale));
|
||||
DEBUG("%s wscale(%u) win change [%u to %u], [allowed|free]space=[%u, %u], mss=%u",
|
||||
__func__, tp->rx_opt.rcv_wscale, free_space, window,
|
||||
allowed_space, free_space, mss);
|
||||
nip_dbg("%s wscale(%u) win change [%u to %u], [allowed|free]space=[%u, %u], mss=%u",
|
||||
__func__, tp->rx_opt.rcv_wscale, free_space, window,
|
||||
allowed_space, free_space, mss);
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -203,8 +202,8 @@ static u16 nip_tcp_select_window(struct sock *sk)
|
||||
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWANTZEROWINDOWADV);
|
||||
new_win_bak = new_win;
|
||||
new_win = ALIGN(cur_win, 1 << tp->rx_opt.rcv_wscale);
|
||||
DEBUG("%s when new_win(%u) < cur_win(%u), win change [%u to %u]",
|
||||
__func__, new_win_bak, cur_win, new_win_bak, new_win);
|
||||
nip_dbg("%s when new_win(%u) < cur_win(%u), win change [%u to %u]",
|
||||
__func__, new_win_bak, cur_win, new_win_bak, new_win);
|
||||
}
|
||||
tp->rcv_wnd = new_win;
|
||||
tp->rcv_wup = tp->rcv_nxt;
|
||||
@@ -222,8 +221,8 @@ static u16 nip_tcp_select_window(struct sock *sk)
|
||||
*/
|
||||
new_win_bak = new_win;
|
||||
new_win >>= tp->rx_opt.rcv_wscale;
|
||||
DEBUG("%s wscale(%u) win change [%u to %u]",
|
||||
__func__, tp->rx_opt.rcv_wscale, new_win_bak, new_win);
|
||||
nip_dbg("%s wscale(%u) win change [%u to %u]",
|
||||
__func__, tp->rx_opt.rcv_wscale, new_win_bak, new_win);
|
||||
if (new_win == 0) {
|
||||
tp->pred_flags = 0;
|
||||
if (old_win)
|
||||
@@ -245,7 +244,6 @@ static void tcp_nip_connect_init(struct sock *sk)
|
||||
const struct dst_entry *dst = __sk_dst_get(sk);
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
__u8 rcv_wscale = 0;
|
||||
int sysctl_tcp_nip_window_scaling = 0;
|
||||
|
||||
/* Header structure length + timestamp length */
|
||||
tp->tcp_header_len = sizeof(struct tcphdr);
|
||||
@@ -271,7 +269,7 @@ static void tcp_nip_connect_init(struct sock *sk)
|
||||
tp->tcp_header_len - sizeof(struct tcphdr) : 0),
|
||||
&tp->rcv_wnd,
|
||||
&tp->window_clamp,
|
||||
sysctl_tcp_nip_window_scaling,
|
||||
0,
|
||||
&rcv_wscale,
|
||||
0);
|
||||
|
||||
@@ -370,7 +368,7 @@ static unsigned int tcp_nip_syn_options(struct sock *sk, struct sk_buff *skb,
|
||||
unsigned int remaining = MAX_TCP_OPTION_SPACE;
|
||||
|
||||
opts->mss = tcp_nip_advertise_mss(sk);
|
||||
DEBUG("advertise mss %d", opts->mss);
|
||||
nip_dbg("advertise mss %d", opts->mss);
|
||||
remaining -= TCPOLEN_MSS_ALIGNED;
|
||||
|
||||
return MAX_TCP_OPTION_SPACE - remaining;
|
||||
@@ -407,11 +405,10 @@ static unsigned int tcp_nip_established_options(struct sock *sk, struct sk_buff
|
||||
static void tcp_nip_options_write(__be32 *ptr, struct tcp_sock *tp,
|
||||
struct tcp_nip_out_options *opts)
|
||||
{
|
||||
if (unlikely(opts->mss)) {
|
||||
if (unlikely(opts->mss))
|
||||
*ptr++ = htonl((TCPOPT_MSS << TCP_OPT_MSS_PAYLOAD) |
|
||||
(TCPOLEN_MSS << TCP_OLEN_MSS_PAYLOAD) |
|
||||
opts->mss);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tcp_nip_event_ack_sent(struct sock *sk, unsigned int pkts,
|
||||
@@ -528,9 +525,9 @@ static int __tcp_nip_transmit_skb(struct sock *sk, struct sk_buff *skb,
|
||||
th->window = htons(min(tp->rcv_wnd, TCP_NIP_WINDOW_MAX));
|
||||
|
||||
ack = tcb->tcp_flags & TCPHDR_ACK;
|
||||
DEBUG("%s sport=%u, dport=%u, win=%u, sk_rcvbuf=%d, sk_rmem_alloc=%d, ack=%u, skb->len=%u",
|
||||
__func__, ntohs(inet->inet_sport), ntohs(inet->inet_dport), ntohs(th->window),
|
||||
sk->sk_rcvbuf, atomic_read(&sk->sk_rmem_alloc), ack, skb->len);
|
||||
nip_dbg("%s sport=%u, dport=%u, win=%u, rcvbuf=%d, sk_rmem_alloc=%d, ack=%u, skb->len=%u",
|
||||
__func__, ntohs(inet->inet_sport), ntohs(inet->inet_dport), ntohs(th->window),
|
||||
sk->sk_rcvbuf, atomic_read(&sk->sk_rmem_alloc), ack, skb->len);
|
||||
|
||||
/* Fill in checksum */
|
||||
check = nip_get_output_checksum_tcp(skb, sk->sk_nip_rcv_saddr, sk->sk_nip_daddr);
|
||||
@@ -623,9 +620,9 @@ unsigned int tcp_nip_sync_mss(struct sock *sk, u32 pmtu)
|
||||
icsk->icsk_mtup.search_high = pmtu;
|
||||
|
||||
mss_now = tcp_nip_mtu_to_mss(sk, pmtu);
|
||||
DEBUG("%s: sync mtu_to_mss %d", __func__, mss_now);
|
||||
nip_dbg("%s: sync mtu_to_mss %d", __func__, mss_now);
|
||||
mss_now = tcp_bound_to_half_wnd(tp, mss_now);
|
||||
DEBUG("%s: sync bound to half wnd %d", __func__, mss_now);
|
||||
nip_dbg("%s: sync bound to half wnd %d", __func__, mss_now);
|
||||
|
||||
/* And store cached results */
|
||||
icsk->icsk_pmtu_cookie = pmtu;
|
||||
@@ -633,7 +630,7 @@ unsigned int tcp_nip_sync_mss(struct sock *sk, u32 pmtu)
|
||||
mss_now = min(mss_now, tcp_nip_mtu_to_mss(sk, icsk->icsk_mtup.search_low));
|
||||
tp->mss_cache = mss_now;
|
||||
|
||||
DEBUG("%s: sync final mss %d", __func__, mss_now);
|
||||
nip_dbg("%s: sync final mss %d", __func__, mss_now);
|
||||
|
||||
return mss_now;
|
||||
}
|
||||
@@ -857,9 +854,9 @@ int __nip_send_synack(struct request_sock *req, struct sk_buff *skb)
|
||||
head.total_len = skb->len;
|
||||
err = nip_send_skb(skb);
|
||||
if (err)
|
||||
DEBUG("%s: failed to send skb, skb->len=%u", __func__, head.total_len);
|
||||
nip_dbg("%s: failed to send skb, skb->len=%u", __func__, head.total_len);
|
||||
else
|
||||
DEBUG("%s: send skb ok, skb->len=%u", __func__, head.total_len);
|
||||
nip_dbg("%s: send skb ok, skb->len=%u", __func__, head.total_len);
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -947,7 +944,7 @@ void tcp_nip_send_fin(struct sock *sk)
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
u32 cur_mss;
|
||||
|
||||
DEBUG("%s: send fin!", __func__);
|
||||
nip_dbg("%s: send fin", __func__);
|
||||
/* Set the fin position of the last packet to 1 */
|
||||
if (tskb && tcp_nip_send_head(sk)) {
|
||||
coalesce:
|
||||
@@ -976,13 +973,15 @@ void tcp_nip_send_active_reset(struct sock *sk, gfp_t priority)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
|
||||
DEBUG("%s: send RST!", __func__);
|
||||
nip_dbg("%s: send RST", __func__);
|
||||
/* NOTE: No TCP options attached and we never retransmit this. */
|
||||
skb = alloc_skb(MAX_TCP_HEADER, priority);
|
||||
if (!skb) {
|
||||
DEBUG("%s: alloc_skb failed.", __func__);
|
||||
if (!skb)
|
||||
/* If you add log here, there will be an alarm:
|
||||
* WARNING: Possible unnecessary 'out of memory' message
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reserve space for headers and prepare control bits. */
|
||||
skb_reserve(skb, MAX_TCP_HEADER);
|
||||
tcp_nip_init_nondata_skb(skb, tcp_nip_acceptable_seq(sk),
|
||||
@@ -1050,7 +1049,7 @@ static bool tcp_nip_write_xmit(struct sock *sk, unsigned int mss_now, int nonagl
|
||||
if (tstamp >= g_ack_to_nxt_snd_tstamp) {
|
||||
ntp->nip_ssthresh = g_ssthresh_low_min;
|
||||
snd_num = ntp->nip_ssthresh / mss_now;
|
||||
SSTHRESH_DBG("%s new snd tstamp %u >= %u, ssthresh %u to %u, snd_num=%u",
|
||||
ssthresh_dbg("%s new snd tstamp %u >= %u, ssthresh %u to %u, snd_num=%u",
|
||||
__func__, tstamp, g_ack_to_nxt_snd_tstamp,
|
||||
last_nip_ssthresh, ntp->nip_ssthresh, snd_num);
|
||||
}
|
||||
@@ -1061,7 +1060,8 @@ static bool tcp_nip_write_xmit(struct sock *sk, unsigned int mss_now, int nonagl
|
||||
|
||||
tcp_nip_init_tso_segs(skb, mss_now);
|
||||
snd_wnd_ready = tcp_nip_snd_wnd_test(tp, skb, mss_now);
|
||||
DEBUG("%s %s, skb->len=%u", __func__, (snd_wnd_ready ? str[1] : str[0]), skb->len);
|
||||
nip_dbg("%s %s, skb->len=%u", __func__,
|
||||
(snd_wnd_ready ? str[1] : str[0]), skb->len);
|
||||
if (unlikely(!snd_wnd_ready))
|
||||
break;
|
||||
|
||||
@@ -1228,7 +1228,7 @@ static int tcp_nip_xmit_probe_skb(struct sock *sk, int urgent, int mib)
|
||||
|
||||
NET_INC_STATS(sock_net(sk), mib);
|
||||
ret = tcp_nip_transmit_skb(sk, skb, 0, (__force gfp_t)0);
|
||||
DEBUG("%s: send %s probe packet, ret=%d", __func__, str[probe_type], ret);
|
||||
nip_dbg("%s: send %s probe packet, ret=%d", __func__, str[probe_type], ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1255,7 +1255,7 @@ int tcp_nip_write_wakeup(struct sock *sk, int mib)
|
||||
err = tcp_fragment(sk, TCP_FRAG_IN_WRITE_QUEUE,
|
||||
skb, seg_size, mss, GFP_ATOMIC);
|
||||
if (err) {
|
||||
DEBUG("%s tcp_fragment return err=%d", __func__, err);
|
||||
nip_dbg("%s tcp_fragment return err=%d", __func__, err);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1284,8 +1284,8 @@ void tcp_nip_send_probe0(struct sock *sk)
|
||||
*/
|
||||
if (tp->packets_out || !tcp_nip_send_head(sk)) {
|
||||
/* Cancel probe timer, if it is not required. */
|
||||
DEBUG("%s packets_out(%u) not 0 or send_head is NULL, cancel probe0 timer.",
|
||||
__func__, tp->packets_out);
|
||||
nip_dbg("%s packets_out(%u) not 0 or send_head is NULL, cancel probe0 timer",
|
||||
__func__, tp->packets_out);
|
||||
icsk->icsk_probes_out = 0;
|
||||
icsk->icsk_backoff = 0;
|
||||
return;
|
||||
@@ -1297,9 +1297,9 @@ void tcp_nip_send_probe0(struct sock *sk)
|
||||
icsk->icsk_backoff++;
|
||||
icsk->icsk_probes_out++; /* Number of probes +1 */
|
||||
probe_max = TCP_RTO_MAX;
|
||||
DEBUG("%s probe0 send %s, icsk_probes_out=%u, icsk_backoff=%u, probe_max=%u",
|
||||
__func__, (!err ? "ok" : "fail"), icsk->icsk_probes_out,
|
||||
icsk->icsk_backoff, probe_max);
|
||||
nip_dbg("%s probe0 send %s, icsk_probes_out=%u, icsk_backoff=%u, probe_max=%u",
|
||||
__func__, (!err ? "ok" : "fail"), icsk->icsk_probes_out,
|
||||
icsk->icsk_backoff, probe_max);
|
||||
} else {
|
||||
/* If packet was not sent due to local congestion,
|
||||
* do not backoff and do not remember icsk_probes_out.
|
||||
@@ -1311,11 +1311,11 @@ void tcp_nip_send_probe0(struct sock *sk)
|
||||
|
||||
/* Makes the zero window probe timer time out faster */
|
||||
probe_max = TCP_RESOURCE_PROBE_INTERVAL;
|
||||
DEBUG("%s probe0 not sent due to local congestion, make timer time out faster",
|
||||
__func__);
|
||||
nip_dbg("%s probe0 not sent due to local congestion, make timer time out faster",
|
||||
__func__);
|
||||
}
|
||||
|
||||
when = tcp_probe0_when(sk, probe_max);
|
||||
DEBUG("%s restart probe0 timer, when=%u, probe_max=%u", __func__, when, probe_max);
|
||||
nip_dbg("%s restart probe0 timer, when=%u, probe_max=%u", __func__, when, probe_max);
|
||||
inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, TCP_RTO_MAX);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ extern bool g_nip_debug;
|
||||
|
||||
/* Debugging of threshold change */
|
||||
extern int g_rtt_ssthresh_debug;
|
||||
#define SSTHRESH_DBG(fmt, ...) \
|
||||
#define ssthresh_dbg(fmt, ...) \
|
||||
do { \
|
||||
if (g_rtt_ssthresh_debug) \
|
||||
pr_crit(fmt, ##__VA_ARGS__); \
|
||||
@@ -97,7 +97,7 @@ do { \
|
||||
|
||||
/* Debugging of packet retransmission after ACK */
|
||||
extern int g_ack_retrans_debug;
|
||||
#define RETRANS_DBG(fmt, ...) \
|
||||
#define retrans_dbg(fmt, ...) \
|
||||
do { \
|
||||
if (g_ack_retrans_debug) \
|
||||
pr_crit(fmt, ##__VA_ARGS__); \
|
||||
|
||||
@@ -100,8 +100,8 @@ static bool retransmits_nip_timed_out(struct sock *sk,
|
||||
* Currently, it determines whether the timeout period is based on
|
||||
* the retransmission times
|
||||
*/
|
||||
DEBUG("%s: icsk->retransmits=%u, boundary=%u", __func__,
|
||||
inet_csk(sk)->icsk_retransmits, boundary);
|
||||
nip_dbg("%s: icsk->retransmits=%u, boundary=%u", __func__,
|
||||
inet_csk(sk)->icsk_retransmits, boundary);
|
||||
return inet_csk(sk)->icsk_retransmits > boundary;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ static int tcp_nip_write_timeout(struct sock *sk)
|
||||
|
||||
if (retransmits_nip_timed_out(sk, retry_until,
|
||||
syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
|
||||
DEBUG("%s: tcp retransmit time out!!!", __func__);
|
||||
nip_dbg("%s: tcp retransmit time out", __func__);
|
||||
tcp_nip_write_err(sk);
|
||||
return 1;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void tcp_nip_retransmit_timer(struct sock *sk)
|
||||
min(icsk->icsk_rto, TCP_RESOURCE_PROBE_INTERVAL),
|
||||
TCP_RTO_MAX);
|
||||
|
||||
SSTHRESH_DBG("%s seq %u retransmit fail, win=%u, rto=%u, pkt_out=%u",
|
||||
ssthresh_dbg("%s seq %u retransmit fail, win=%u, rto=%u, pkt_out=%u",
|
||||
__func__, scb->seq, ntp->nip_ssthresh,
|
||||
icsk->icsk_rto, tp->packets_out);
|
||||
return;
|
||||
@@ -172,7 +172,7 @@ void tcp_nip_retransmit_timer(struct sock *sk)
|
||||
icsk_rto_last = icsk->icsk_rto;
|
||||
icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
|
||||
|
||||
SSTHRESH_DBG("%s seq %u, reset win %u to %u, rto %u to %u, pkt_out=%u",
|
||||
ssthresh_dbg("%s seq %u, reset win %u to %u, rto %u to %u, pkt_out=%u",
|
||||
__func__, scb->seq, ntp->nip_ssthresh, g_ssthresh_low,
|
||||
icsk_rto_last, icsk->icsk_rto, tp->packets_out);
|
||||
|
||||
@@ -192,8 +192,8 @@ void tcp_nip_probe_timer(struct sock *sk)
|
||||
if (tp->packets_out || !tcp_nip_send_head(sk)) {
|
||||
icsk->icsk_probes_out = 0;
|
||||
icsk->icsk_backoff = 0; // V4 no modified this line
|
||||
DEBUG("%s packets_out(%u) not 0 or send_head is NULL, cancel probe0 timer.",
|
||||
__func__, tp->packets_out);
|
||||
nip_dbg("%s packets_out(%u) not 0 or send_head is NULL, cancel probe0 timer",
|
||||
__func__, tp->packets_out);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,11 +204,11 @@ void tcp_nip_probe_timer(struct sock *sk)
|
||||
const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX;
|
||||
|
||||
max_probes = tcp_nip_orphan_retries(sk, alive);
|
||||
DEBUG("%s sock dead, icsk_backoff=%u, max_probes=%u, alive=%u",
|
||||
__func__, icsk->icsk_backoff, max_probes, alive);
|
||||
nip_dbg("%s sock dead, icsk_backoff=%u, max_probes=%u, alive=%u",
|
||||
__func__, icsk->icsk_backoff, max_probes, alive);
|
||||
if (!alive && icsk->icsk_backoff >= max_probes) {
|
||||
DEBUG("%s will close session, icsk_backoff=%u, max_probes=%u",
|
||||
__func__, icsk->icsk_backoff, max_probes);
|
||||
nip_dbg("%s will close session, icsk_backoff=%u, max_probes=%u",
|
||||
__func__, icsk->icsk_backoff, max_probes);
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
@@ -216,14 +216,14 @@ void tcp_nip_probe_timer(struct sock *sk)
|
||||
if (icsk->icsk_probes_out >= max_probes) {
|
||||
abort: icsk_backoff = icsk->icsk_backoff;
|
||||
icsk_probes_out = icsk->icsk_probes_out;
|
||||
DEBUG("%s close session, icsk_probes_out=%u, icsk_backoff=%u, max_probes=%u",
|
||||
__func__, icsk_probes_out, icsk_backoff, max_probes);
|
||||
nip_dbg("%s close session, icsk_probes_out=%u, icsk_backoff=%u, max_probes=%u",
|
||||
__func__, icsk_probes_out, icsk_backoff, max_probes);
|
||||
tcp_nip_write_err(sk);
|
||||
} else {
|
||||
icsk_backoff = icsk->icsk_backoff;
|
||||
icsk_probes_out = icsk->icsk_probes_out;
|
||||
DEBUG("%s will send probe0, icsk_probes_out=%u, icsk_backoff=%u, max_probes=%u",
|
||||
__func__, icsk_probes_out, icsk_backoff, max_probes);
|
||||
nip_dbg("%s will send probe0, icsk_probes_out=%u, icsk_backoff=%u, max_probes=%u",
|
||||
__func__, icsk_probes_out, icsk_backoff, max_probes);
|
||||
/* Only send another probe if we didn't close things up. */
|
||||
tcp_nip_send_probe0(sk);
|
||||
}
|
||||
@@ -294,8 +294,8 @@ static bool tcp_nip_keepalive_is_timeout(struct sock *sk, u32 elapsed)
|
||||
ntp->nip_keepalive_out > 0) ||
|
||||
(icsk->icsk_user_timeout == 0 &&
|
||||
ntp->nip_keepalive_out >= keepalive_probes(tp))) {
|
||||
DEBUG("%s normal keepalive timeout, keepalive_out=%u.",
|
||||
__func__, ntp->nip_keepalive_out);
|
||||
nip_dbg("%s normal keepalive timeout, keepalive_out=%u",
|
||||
__func__, ntp->nip_keepalive_out);
|
||||
tcp_nip_write_err(sk);
|
||||
is_timeout = true;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ static void tcp_nip_keepalive_timer(struct timer_list *t)
|
||||
}
|
||||
|
||||
if (sk->sk_state == TCP_LISTEN) {
|
||||
DEBUG("%s: keepalive on a LISTEN", __func__);
|
||||
nip_dbg("%s: keepalive on a LISTEN", __func__);
|
||||
goto out;
|
||||
}
|
||||
tcp_mstamp_refresh(tp);
|
||||
@@ -330,7 +330,7 @@ static void tcp_nip_keepalive_timer(struct timer_list *t)
|
||||
*/
|
||||
if ((sk->sk_state == TCP_FIN_WAIT2 || sk->sk_state == TCP_CLOSING) &&
|
||||
sock_flag(sk, SOCK_DEAD)) {
|
||||
DEBUG("%s: finish wait, close sock, sk_state=%u", __func__, sk->sk_state);
|
||||
nip_dbg("%s: finish wait, close sock, sk_state=%u", __func__, sk->sk_state);
|
||||
goto death;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ struct sock *__nip_udp_lib_lookup(struct net *net,
|
||||
|
||||
if (hslot->count > NIP_UDP_HSLOT_COUNT) {
|
||||
hash2 = nip_udp_portaddr_hash(net, daddr, hnum);
|
||||
DEBUG("hash2 is: 0x%x", hash2);
|
||||
slot2 = hash2 & udptable->mask;
|
||||
hslot2 = &udptable->hash2[slot2];
|
||||
if (hslot->count < hslot2->count)
|
||||
@@ -200,7 +199,6 @@ begin:
|
||||
result = sk;
|
||||
badness = score;
|
||||
}
|
||||
DEBUG("score is: %d", score);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -242,10 +240,8 @@ int nip_udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
|
||||
|
||||
/* copy data */
|
||||
datalen = copy_to_iter(skb->data, copied, &msg->msg_iter);
|
||||
|
||||
if (datalen < 0) {
|
||||
DEBUG("%s: copy to iter in failure! len = %d", __func__,
|
||||
datalen);
|
||||
nip_dbg("%s: copy to iter in failure, len=%d", __func__, datalen);
|
||||
err = -EFAULT;
|
||||
return err;
|
||||
}
|
||||
@@ -317,8 +313,7 @@ int nip_udp_input(struct sk_buff *skb)
|
||||
struct udphdr *udphead = udp_hdr(skb);
|
||||
|
||||
if (!nip_get_udp_input_checksum(skb)) {
|
||||
DEBUG("%s: checksum failed, drop the packet. ",
|
||||
__func__);
|
||||
nip_dbg("%s: checksum failed, drop the packet", __func__);
|
||||
kfree_skb(skb);
|
||||
rc = -1;
|
||||
goto end;
|
||||
@@ -327,8 +322,9 @@ int nip_udp_input(struct sk_buff *skb)
|
||||
sk = __nip_udp_lib_lookup_skb(skb, udphead->source,
|
||||
udphead->dest, &udp_table);
|
||||
if (!sk) {
|
||||
DEBUG("%s: dport not match, drop the packet. sport=%u, dport=%u, data_len=%u.",
|
||||
__func__, ntohs(udphead->source), ntohs(udphead->dest), ntohs(udphead->len));
|
||||
nip_dbg("%s: dport not match, drop the packet. sport=%u, dport=%u, data_len=%u",
|
||||
__func__, ntohs(udphead->source),
|
||||
ntohs(udphead->dest), ntohs(udphead->len));
|
||||
kfree_skb(skb);
|
||||
rc = -1;
|
||||
goto end;
|
||||
@@ -353,19 +349,18 @@ int nip_udp_output(struct sock *sk, struct msghdr *msg, size_t len)
|
||||
int err = 0;
|
||||
struct inet_sock *inet;
|
||||
|
||||
if (!sin) {
|
||||
if (!sin)
|
||||
/* Currently, udp socket Connect function is not implemented.
|
||||
* The destination address and port must be directly provided by Sendto
|
||||
*/
|
||||
return -EDESTADDRREQ;
|
||||
}
|
||||
|
||||
if (sin->sin_family != AF_NINET) {
|
||||
DEBUG("%s: sin_family false.", __func__);
|
||||
nip_dbg("%s: sin_family false", __func__);
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
if (nip_addr_invalid(&sin->sin_addr)) {
|
||||
DEBUG("%s: sin_addr false.", __func__);
|
||||
nip_dbg("%s: sin_addr false", __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user