Compare commits

...

8 Commits

Author SHA1 Message Date
Mateusz Bajorski
07223eec2b ucentral-pstore: Disable printing processed lines
When processing huge console log and dmesg files printing lines
hanged execution blocking ucentral-state startup process.

It seems stdout is mainly for debug purposes and lines are
printed after we store file, so it is safe to disable print
as file is already processed and can be examined.

Fixes: WIFI-15356

Signed-off-by: Mateusz Bajorski <mbajorski@shasta.cloud>
Signed-off-by: Marek Kwaczynski <marek@shasta.cloud>
2026-03-19 07:22:26 +01:00
John Crispin
e2a36d1a4e ucentral-event: remove debug logging from strict forwarding
Remove logger calls that were left in from development. The FDB
entries are observable via 'bridge fdb show' and do not need runtime
logging in production.

Signed-off-by: John Crispin <john@phrozen.org>
2026-03-19 07:21:54 +01:00
John Crispin
e4bbbb1ee5 udhcpinject: fix UDP pseudo-header address extraction
ntohs() on a right-shifted __be32 produces garbage because the shift
operates on the network-order representation. Use ntohl() first to
convert to host order, then extract the 16-bit halves.

Signed-off-by: John Crispin <john@phrozen.org>
2026-03-19 07:21:46 +01:00
Kumiko18
0cefc067b7 ucentral-event: add FDB management for strict forwarding
When strict forwarding is enabled, DHCP packets fail to forward
because the bridge lacks static FDB entries for client MACs in the
correct VLAN. Add per-station static FDB entries tagged with the
bridge PVID on sta-authorized and remove them on disconnect.

Signed-off-by: John Crispin <john@phrozen.org>
2026-03-19 07:21:38 +01:00
Kumiko18
213335c44d udhcpinject: fix IP and UDP checksum calculation
The checksum code mixes host and network byte order inconsistently,
producing corrupt UDP checksums. Switch to consistently working in
host byte order using ntohs() on each word before summing, and
htons() on the final result.

Signed-off-by: John Crispin <john@phrozen.org>
2026-03-19 07:21:29 +01:00
jaspreetsachdev
222b17415c Merge pull request #1016 from Telecominfraproject/main
merge for v4.2.2
2026-03-04 15:04:30 -05:00
jaspreetsachdev
a01b9ac0f4 Merge pull request #1002 from Telecominfraproject/main
4.2.1 merge
2026-02-05 13:29:08 -05:00
jaspreetsachdev
a00dbfa6e4 Merge pull request #985 from Telecominfraproject/main
merge for 4.2.0 RC2
2025-12-12 18:42:38 -05:00
3 changed files with 77 additions and 35 deletions

View File

@@ -112,6 +112,35 @@ function get_bridge_interfaces(bridge){
return dir;
}
function get_bridge_pvid(ifname) {
let f = fs.popen(`bridge -j vlan show dev ${ifname} 2>/dev/null`);
if (!f) return null;
let data = json(f.read("all"));
f.close();
if (!data) return null;
for (let entry in data)
for (let v in entry?.vlans)
if (v?.flags && index(v.flags, "PVID") >= 0)
return v.vlan;
return null;
}
function strict_fwd_update_fdb(hapd, address) {
if (!+hapd?.config?.strict_forwarding)
return;
let pvid = get_bridge_pvid(hapd.ifname);
if (pvid)
system(`bridge fdb replace ${address} dev ${hapd.ifname} master static vlan ${pvid}`);
}
function strict_fwd_delete_fdb(hapd, address) {
if (!+hapd?.config?.strict_forwarding)
return;
let pvid = get_bridge_pvid(hapd.ifname);
if (pvid)
system(`bridge fdb del ${address} dev ${hapd.ifname} master vlan ${pvid} 2>/dev/null`);
}
function event(object, verb, payload) {
let type = object;
if (verb)
@@ -226,6 +255,8 @@ handlers = {
msg.defaults = hapd.ssid;
ubus.call('ratelimit', 'client_set', msg);
}
strict_fwd_update_fdb(hapd, notify.data.address);
},
'channel-switch' : function(notify, hapd) {
@@ -240,6 +271,7 @@ handlers = {
};
ubus.call('ratelimit', 'client_delete', msg);
}
strict_fwd_delete_fdb(hapd, notify.data.address);
},
'key-mismatch': function(notify, hapd) {

View File

@@ -23,7 +23,6 @@ function move_to_json(src, dst) {
msg[fs.basename(dst)] = lines;
fd.write(msg);
fd.close();
print(lines);
}
move_to_json('/sys/fs/pstore/dmesg-ramoops-0', '/tmp/crashlog');

View File

@@ -392,48 +392,59 @@ void process_packet(unsigned char *user, const struct pcap_pkthdr *header,
new_ip->tot_len = htons(ntohs(ip->tot_len) + opt82_len);
new_udp->len = htons(ntohs(udp->len) + opt82_len);
// Recalculate IP checksum
// Reset checksum to 0 before recalculating
new_ip->check = 0;
unsigned int sum = 0;
unsigned short *ip_ptr = (unsigned short *)new_ip;
for (int i = 0; i < ip->ihl * 2; i++)
{
sum += *ip_ptr++;
}
while (sum >> 16)
{
sum = (sum & 0xFFFF) + (sum >> 16);
}
new_ip->check = ~sum;
// Recalculate UDP checksum
// Calculate checksum
uint32_t sum = 0;
uint16_t *ptr = (uint16_t *)new_ip;
int len = new_ip->ihl * 4;
for (int i = 0; i < len / 2; i++) {
sum += ntohs(ptr[i]);
}
// Fold 32-bit sum into 16 bits
while (sum >> 16)
sum = (sum & 0xFFFF) + (sum >> 16);
new_ip->check = htons((uint16_t)~sum);
// Reset checksum to 0 before recalculating
new_udp->check = 0;
sum = 0;
// Pseudo-header
sum +=
(ntohs(new_ip->saddr) & 0xFFFF) + (ntohs(new_ip->saddr >> 16) & 0xFFFF);
sum +=
(ntohs(new_ip->daddr) & 0xFFFF) + (ntohs(new_ip->daddr >> 16) & 0xFFFF);
sum += htons(IPPROTO_UDP);
sum += new_udp->len;
// UDP header and data
unsigned char *udp_start = (unsigned char *)new_udp;
int udp_total_len = ntohs(new_udp->len);
unsigned short *udp_ptr = (unsigned short *)udp_start;
for (int i = 0; i < udp_total_len / 2; i++)
{
sum += *udp_ptr++;
// Build pseudo-header and compute checksum
sum = 0;
uint16_t udp_len = ntohs(new_udp->len);
uint32_t saddr = ntohl(new_ip->saddr);
uint32_t daddr = ntohl(new_ip->daddr);
sum += (saddr >> 16) & 0xFFFF;
sum += saddr & 0xFFFF;
sum += (daddr >> 16) & 0xFFFF;
sum += daddr & 0xFFFF;
sum += IPPROTO_UDP;
sum += udp_len;
// Sum the UDP header + payload
ptr = (uint16_t *)new_udp;
int i;
for (i = 0; i < udp_len / 2; i++) {
sum += ntohs(ptr[i]);
}
if (udp_total_len % 2)
{
sum += *(unsigned char *)udp_ptr;
// If odd length, pad last byte
if (udp_len & 1) {
sum += ((uint8_t *)new_udp)[udp_len - 1] << 8;
}
// Fold 32-bit sum into 16 bits
while (sum >> 16)
{
sum = (sum & 0xFFFF) + (sum >> 16);
}
new_udp->check = ~sum;
new_udp->check = htons((uint16_t)~sum);
// UDP allows 0xFFFF instead of 0x0000 (0 means "no checksum")
if (new_udp->check == 0)
new_udp->check = 0xFFFF;