1、NewIP Kconfig调用sh脚本判断NewIP代码目录是否存在,自动使能NewIP。

目前内核使用代码仓代码生成某个款型最终.config文件,因此NewIP Kconfig先使用代码仓相对路径,等内核整改后根据out目录生成某个款型最终.config文件后,再修改成out目录相对路径。
2、内核编译告警修复
3、tcp_nip_rcv函数丢包流程增加debug

Signed-off-by: yangyanjun <yangyanjun@huawei.com>
This commit is contained in:
yangyanjun
2022-11-09 16:35:12 +08:00
parent d3b89c35df
commit edd5b1f9ab
8 changed files with 58 additions and 44 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ static int _nip_update_recv_skb_len(struct sk_buff *skb,
static int nip_rcv_finish(struct sk_buff *skb)
{
struct net *net = dev_net(skb->dev);
void (*edemux)(struct sk_buff *skb);
void (*edemux)(struct sk_buff *skb) = NULL;
/* set /proc/sys/net/ipv4/ip_early_demux to change sysctl_ip_early_demux,
* which is used by ipv4, ipv6 and newip
+1 -2
View File
@@ -312,8 +312,7 @@ static int nip_dst_lookup_tail(struct net *net, const struct sock *sk,
rt = (struct nip_rt_info *)*dst;
if (*dst == &net->newip.nip_broadcast_entry->dst) {
if (!&fln->saddr)
fln->saddr = fln->daddr;
fln->saddr = fln->daddr;
err = 0;
} else {
err = nip_route_get_saddr(net, rt, &fln->daddr, &fln->saddr);
+28 -21
View File
@@ -1108,7 +1108,7 @@ int tcp_nip_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonbloc
int copied = 0;
u32 *seq;
unsigned long used;
int err;
int err = 0;
int target;
long timeo;
size_t len_tmp = len;
@@ -1381,25 +1381,35 @@ static int tcp_nip_rcv(struct sk_buff *skb)
int ret;
int dif = skb->skb_iif;
if (skb->pkt_type != PACKET_HOST)
if (skb->pkt_type != PACKET_HOST) {
DEBUG("%s unknown pkt-type(%u), drop skb.", __func__, skb->pkt_type);
goto discard_it;
}
if (!nip_get_tcp_input_checksum(skb))
if (!nip_get_tcp_input_checksum(skb)) {
DEBUG("%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))
goto bad_packet;
if (unlikely(th->doff < sizeof(struct tcphdr) / TCP_NUM_4)) {
DEBUG("%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)
th->source, th->dest, dif, &refcounted);
if (!sk) {
DEBUG("%s: can`t find related sock for skb, will disconnect.", __func__);
goto no_tcp_socket;
}
if (sk->sk_state == TCP_TIME_WAIT)
goto do_time_wait;
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__);
goto discard_it;
}
if (sk->sk_state == TCP_NEW_SYN_RECV) {
struct request_sock *req = inet_reqsk(sk);
struct sock *nsk;
@@ -1420,11 +1430,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!!!", __func__);
DEBUG("%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__);
goto discard_and_relse;
} else {
sock_put(sk);
@@ -1434,8 +1445,10 @@ static int tcp_nip_rcv(struct sk_buff *skb)
tcp_nip_fill_cb(skb, th);
if (tcp_filter(sk, skb))
if (tcp_filter(sk, skb)) {
DEBUG("%s tcp filter fail, drop skb.", __func__);
goto discard_and_relse;
}
th = (const struct tcphdr *)skb->data;
skb->dev = NULL;
@@ -1453,8 +1466,10 @@ static int tcp_nip_rcv(struct sk_buff *skb)
} else {
DEBUG("%s: sock locked by user! put packet into backlog",
__func__);
if (tcp_nip_add_backlog(sk, skb))
if (tcp_nip_add_backlog(sk, skb)) {
DEBUG("%s add backlog fail, drop skb.", __func__);
goto discard_and_relse;
}
}
bh_unlock_sock(sk);
@@ -1465,14 +1480,9 @@ put_and_return:
return ret ? -1 : 0;
no_tcp_socket:
/* Checksum checked, send reset back */
tcp_nip_send_reset(NULL, skb);
DEBUG("%s: cannot find related tcp sock for skb", __func__);
goto discard_it;
bad_packet:
goto discard_it;
discard_it:
DEBUG("%s: drop tcp newip skb and release it", __func__);
kfree_skb(skb);
return 0;
@@ -1481,9 +1491,6 @@ discard_and_relse:
if (refcounted)
sock_put(sk);
goto discard_it;
/* Handles the SK portion of the interrupt state */
do_time_wait:
goto discard_it;
}
static void tcp_nip_early_demux(struct sk_buff *skb)
+2 -2
View File
@@ -429,7 +429,7 @@ static int tcp_nip_clean_rtx_queue(struct sock *sk, ktime_t *skb_snd_tstamp)
while ((skb = tcp_write_queue_head(sk)) && skb != tcp_nip_send_head(sk)) {
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
u32 acked_pcount;
u32 acked_pcount = 0;
if (after(scb->end_seq, tp->snd_una)) {
if (tcp_skb_pcount(skb) == 1 || !after(tp->snd_una, scb->seq))
@@ -827,7 +827,7 @@ int _tcp_nip_conn_request(struct request_sock_ops *rsk_ops,
/* The best way to do this is to prink the value of user_mss and see if it is 0 */
tmp_opt.user_mss = tp->rx_opt.user_mss;
/* Parsing of TCP options in SKB */
tcp_nip_parse_options(skb, &tmp_opt, 0, false);
tcp_nip_parse_options(skb, &tmp_opt, 0, NULL);
/* Tstamp_ok indicates the TIMESTAMP seen on the received SYN packet */
tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
+10 -11
View File
@@ -166,19 +166,18 @@ u32 __nip_tcp_select_window(struct sock *sk)
/* Don't do rounding if we are using window scaling, since the
* scaled window will not line up with the MSS boundary anyway.
* tp->rx_opt.rcv_wscale is always true
*/
if (tp->rx_opt.rcv_wscale) {
window = free_space;
window = free_space;
/* Advertise enough space so that it won't get scaled away.
* Import case: prevent zero window announcement if
* 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);
}
/* Advertise enough space so that it won't get scaled away.
* Import case: prevent zero window announcement if
* 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);
return window;
}
+6
View File
@@ -136,6 +136,12 @@ module_param_named(nip_keepalive_time, g_nip_keepalive_time, int, 0644);
int g_nip_keepalive_intvl = 25;
module_param_named(nip_keepalive_intvl, g_nip_keepalive_intvl, int, 0644);
/*********************************************************************************************/
/* probe parameters */
/*********************************************************************************************/
int g_nip_probe_max = 2000;
module_param_named(nip_probe_max, g_nip_probe_max, int, 0644);
/*********************************************************************************************/
/* window mode parameters */
/*********************************************************************************************/
+6 -1
View File
@@ -76,6 +76,11 @@ extern int g_nip_keepalive_intvl;
extern bool g_nip_tcp_snd_win_enable;
extern bool g_nip_tcp_rcv_win_enable;
/*********************************************************************************************/
/* probe parameters */
/*********************************************************************************************/
extern int g_nip_probe_max;
/*********************************************************************************************/
/* nip debug parameters */
/*********************************************************************************************/
@@ -92,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__); \
+4 -6
View File
@@ -181,7 +181,6 @@ void tcp_nip_retransmit_timer(struct sock *sk)
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX);
}
#define NIP_MAX_PROBES 2000
void tcp_nip_probe_timer(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
@@ -198,11 +197,8 @@ void tcp_nip_probe_timer(struct sock *sk)
return;
}
#ifdef NIP_MAX_PROBES
max_probes = NIP_MAX_PROBES; // 2000 - fix session auto close
#else
max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2;
#endif
/* default: sock_net(sk)->ipv4.sysctl_tcp_retries2 */
max_probes = g_nip_probe_max; /* fix session auto close */
if (sock_flag(sk, SOCK_DEAD)) {
const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX;
@@ -224,6 +220,8 @@ abort: icsk_backoff = icsk->icsk_backoff;
__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);
/* Only send another probe if we didn't close things up. */