summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-06-19 16:13:33 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-06-19 16:13:33 (GMT)
commitf4345e75920e10815cf6221bc9645fcef9637075 (patch)
treeade4115f911393556bfc13c52c9f51da4394c11f /SylixOS
parent7ade7463417076c9f5e8f7230632540684de0c8c (diff)
downloadlibsylixos-f4345e75920e10815cf6221bc9645fcef9637075.zip
libsylixos-f4345e75920e10815cf6221bc9645fcef9637075.tar.gz
libsylixos-f4345e75920e10815cf6221bc9645fcef9637075.tar.bz2
Fixed TCP retransmit with NAT port map bug.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/kernel/core/_WakeupLine.c8
-rw-r--r--SylixOS/kernel/include/k_cpu.h6
-rw-r--r--SylixOS/kernel/include/k_kernel.h2
-rw-r--r--SylixOS/kernel/show/InterShow.c17
-rw-r--r--SylixOS/net/lwip/src/core/tcp_out.c8
-rw-r--r--SylixOS/net/lwip/tools/nat/lwip_natlib.c7
6 files changed, 34 insertions, 14 deletions
diff --git a/SylixOS/kernel/core/_WakeupLine.c b/SylixOS/kernel/core/_WakeupLine.c
index abe6158..0c058fc 100644
--- a/SylixOS/kernel/core/_WakeupLine.c
+++ b/SylixOS/kernel/core/_WakeupLine.c
@@ -164,9 +164,11 @@ VOID _WakeupStatus (PLW_CLASS_WAKEUP pwu, PLW_CLASS_WAKEUP_NODE pwun, ULONG
}
if (plineTemp) {
- __KERNEL_TIME_GET_NO_SPINLOCK(i64CurTime, INT64);
- ulDelta = (ULONG)(i64CurTime - pwu->WU_i64LastTime);
- ulCounter = (ulCounter > ulDelta) ? (ulCounter - ulDelta) : 0ul;
+ if (pwu->WU_i64LastTime) { /* 包含时间预处理 */
+ __KERNEL_TIME_GET_NO_SPINLOCK(i64CurTime, INT64);
+ ulDelta = (ULONG)(i64CurTime - pwu->WU_i64LastTime);
+ ulCounter = (ulCounter > ulDelta) ? (ulCounter - ulDelta) : 0ul;
+ }
*pulLeft = ulCounter;
} else {
diff --git a/SylixOS/kernel/include/k_cpu.h b/SylixOS/kernel/include/k_cpu.h
index 4ed1654..22002eb 100644
--- a/SylixOS/kernel/include/k_cpu.h
+++ b/SylixOS/kernel/include/k_cpu.h
@@ -179,9 +179,9 @@ typedef struct {
} LW_CLASS_CPUSET;
typedef LW_CLASS_CPUSET *PLW_CLASS_CPUSET;
-#define LW_CPU_SET(n, p) ((p)->cpus_bits[(n) / LW_NCPUBITS] |= (ULONG)( (1u << ((n) % LW_NCPUBITS))))
-#define LW_CPU_CLR(n, p) ((p)->cpus_bits[(n) / LW_NCPUBITS] &= (ULONG)(~(1u << ((n) % LW_NCPUBITS))))
-#define LW_CPU_ISSET(n, p) ((p)->cpus_bits[(n) / LW_NCPUBITS] & (ULONG)( (1u << ((n) % LW_NCPUBITS))))
+#define LW_CPU_SET(n, p) ((p)->cpus_bits[(n) / LW_NCPUBITS] |= (ULONG)( (1ul << ((n) % LW_NCPUBITS))))
+#define LW_CPU_CLR(n, p) ((p)->cpus_bits[(n) / LW_NCPUBITS] &= (ULONG)(~(1ul << ((n) % LW_NCPUBITS))))
+#define LW_CPU_ISSET(n, p) ((p)->cpus_bits[(n) / LW_NCPUBITS] & (ULONG)( (1ul << ((n) % LW_NCPUBITS))))
#define LW_CPU_ZERO(p) lib_bzero((PVOID)(p), sizeof(*(p)))
/*********************************************************************************************************
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index ed3ea29..f3decd5 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -51,7 +51,7 @@
#define __SYLIXOS_MAJOR_VER 1
#define __SYLIXOS_MINOR_VER 12
-#define __SYLIXOS_PATCH_VER 2
+#define __SYLIXOS_PATCH_VER 3
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
diff --git a/SylixOS/kernel/show/InterShow.c b/SylixOS/kernel/show/InterShow.c
index 67f0ed1..7c5f9b1 100644
--- a/SylixOS/kernel/show/InterShow.c
+++ b/SylixOS/kernel/show/InterShow.c
@@ -51,14 +51,14 @@ extern LW_OBJECT_HANDLE _K_ulInterShowLock;
*********************************************************************************************************/
#if LW_CFG_CPU_WORD_LENGHT == 64
static const CHAR _G_cInterInfoHdr1[] = "\n\
- IRQ NAME ENTRY CLEAR ENABLE RND PREEMPT";
+ IRQ NAME ENTRY CLEAR ENABLE RND PREEMPT PRIO";
static const CHAR _G_cInterInfoHdr2[] = "\n\
----- -------------- ---------------- ---------------- ------ --- -------";
+---- -------------- ---------------- ---------------- ------ --- ------- ----";
#else
static const CHAR _G_cInterInfoHdr1[] = "\n\
- IRQ NAME ENTRY CLEAR ENABLE RND PREEMPT";
+ IRQ NAME ENTRY CLEAR ENABLE RND PREEMPT PRIO";
static const CHAR _G_cInterInfoHdr2[] = "\n\
----- -------------- -------- -------- ------ --- -------";
+---- -------------- -------- -------- ------ --- ------- ----";
#endif /* LW_CFG_CPU_WORD_LENGHT adj */
#if LW_CFG_INTER_INFO > 0
@@ -87,6 +87,8 @@ VOID API_InterShow (ULONG ulCPUStart, ULONG ulCPUEnd)
PCHAR pcRnd;
PCHAR pcPreem;
ULONG ulFlag;
+ UINT uiPrio = 0;
+ INT iRet;
PLW_CLASS_INTDESC pidesc;
PLW_CLASS_INTACT piaction;
@@ -120,6 +122,7 @@ VOID API_InterShow (ULONG ulCPUStart, ULONG ulCPUEnd)
for (i = 0; i < LW_CFG_MAX_INTER_SRC; i++) {
API_InterVectorGetFlag((ULONG)i, &ulFlag);
API_InterVectorIsEnable((ULONG)i, &bIsEnable);
+ iRet = API_InterVectorGetPriority((ULONG)i, &uiPrio);
pcIsEnable = (bIsEnable) ? "true" : "false";
pcRnd = (ulFlag & LW_IRQ_FLAG_SAMPLE_RAND) ? "yes" : "";
@@ -145,6 +148,12 @@ VOID API_InterShow (ULONG ulCPUStart, ULONG ulCPUEnd)
pcIsEnable,
pcRnd,
pcPreem);
+
+ if (iRet) { /* 打印优先级 */
+ printf("N/A ");
+ } else {
+ printf("%4d ", uiPrio);
+ }
for (j = ulCPUStart; j <= ulCPUEnd; j++) { /* 打印中断计数 */
printf("%13lld ", piaction->IACT_iIntCnt[j]);
diff --git a/SylixOS/net/lwip/src/core/tcp_out.c b/SylixOS/net/lwip/src/core/tcp_out.c
index bfb033b..f53ee1e 100644
--- a/SylixOS/net/lwip/src/core/tcp_out.c
+++ b/SylixOS/net/lwip/src/core/tcp_out.c
@@ -1550,6 +1550,14 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif
/** Exclude retransmitted segments from this count. */
MIB2_STATS_INC(mib2.tcpoutsegs);
}
+#if LW_CFG_NET_NAT_EN > 0 /* SylixOS Add NAT retransmitted source port reset */
+ else {
+ /** NAT output local tcp packet will change the packet source port
+ * If this is retransmit packet the header source port has already changed
+ * so here we change it back */
+ seg->tcphdr->src = lwip_htons(pcb->local_port);
+ }
+#endif /* LW_CFG_NET_NAT_EN */
seg->p->len -= len;
seg->p->tot_len -= len;
diff --git a/SylixOS/net/lwip/tools/nat/lwip_natlib.c b/SylixOS/net/lwip/tools/nat/lwip_natlib.c
index 824cf9d..157f44b 100644
--- a/SylixOS/net/lwip/tools/nat/lwip_natlib.c
+++ b/SylixOS/net/lwip/tools/nat/lwip_natlib.c
@@ -1259,8 +1259,9 @@ static struct pbuf *__natIpInput (struct pbuf *p, struct netif *pnetifIn, stru
iphdr = (struct ip_hdr *)p->payload;
- if (!ip4_addr_cmp(&iphdr->dest, netif_ip4_addr(pnetifIn))) {
- return (p);
+ if (!ip4_addr_cmp(&iphdr->dest, netif_ip4_addr(pnetifIn))) { /* 只允许发送至本机 */
+ pbuf_free(p);
+ return (LW_NULL);
}
if (IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) { /* 分片数据包 */
@@ -1902,7 +1903,7 @@ static ssize_t __procFsNatAssNodeRead (PLW_PROCFS_NODE p_pfsn,
off_t oft)
{
const CHAR cNatInfoHeader[] = "\n"
- " LOCAL IP LOCAL PORT ASS PORT PROTO IDLE(min) STATUS\n"
+ " LOCAL IP LOCAL PORT ASS PORT PROTO IDLE(sec) STATUS\n"
"--------------- ---------- -------- ----- --------- --------\n";
PCHAR pcFileBuffer;