mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-26 00:52:50 +00:00
fix(net): Correct QEMU gateway ARP MAC address, enable dynamic ARP sender learning, and add run-remote target
This commit is contained in:
1 parent
9f3cfe5d54
commit
8a90d88f70
2 files changed
+11
-2
No files matched your search
@@ -123,6 +123,12 @@ run-server: $(IMAGE)
|
|||||||
-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \
|
-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \
|
||||||
-device e1000,netdev=net0 -serial stdio -display none
|
-device e1000,netdev=net0 -serial stdio -display none
|
||||||
|
|
||||||
|
run-remote: $(IMAGE)
|
||||||
|
qemu-system-x86_64 -drive format=raw,file=$(IMAGE) \
|
||||||
|
-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \
|
||||||
|
-device e1000,netdev=net0 \
|
||||||
|
-serial telnet:0.0.0.0:2222,server,nowait -display none
|
||||||
|
|
||||||
debug: $(IMAGE)
|
debug: $(IMAGE)
|
||||||
qemu-system-x86_64 -drive format=raw,file=$(IMAGE) \
|
qemu-system-x86_64 -drive format=raw,file=$(IMAGE) \
|
||||||
-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \
|
-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \
|
||||||
|
|||||||
+5
-2
@@ -235,6 +235,9 @@ void net_receive(const uint8_t* packet, uint16_t length) {
|
|||||||
const ip_header_t* ip = (const ip_header_t*)payload;
|
const ip_header_t* ip = (const ip_header_t*)payload;
|
||||||
uint8_t ihl = (ip->ihl_version & 0x0F) * 4;
|
uint8_t ihl = (ip->ihl_version & 0x0F) * 4;
|
||||||
if (payload_len >= ihl) {
|
if (payload_len >= ihl) {
|
||||||
|
// Dynamically learn sender's MAC address in ARP cache
|
||||||
|
arp_cache_insert(ip->src_ip, eth->src_mac);
|
||||||
|
|
||||||
// NetFilter inspection hook
|
// NetFilter inspection hook
|
||||||
if (filter_evaluate(FILTER_HOOK_LOCAL_IN, ip->protocol, ip->src_ip, ip->dst_ip, 0, 0, payload_len) == FILTER_ACTION_DROP) {
|
if (filter_evaluate(FILTER_HOOK_LOCAL_IN, ip->protocol, ip->src_ip, ip->dst_ip, 0, 0, payload_len) == FILTER_ACTION_DROP) {
|
||||||
return; // Dropped by firewall
|
return; // Dropped by firewall
|
||||||
@@ -315,8 +318,8 @@ void net_init(void) {
|
|||||||
primary_if.dns = ip_parse("10.0.2.3");
|
primary_if.dns = ip_parse("10.0.2.3");
|
||||||
primary_if.is_up = true;
|
primary_if.is_up = true;
|
||||||
|
|
||||||
// Seed gateway in ARP cache
|
// Seed gateway in ARP cache (QEMU Virtual Router MAC)
|
||||||
uint8_t qemu_gw[6] = {0x52, 0x54, 0x00, 0x12, 0x34, 0x56};
|
uint8_t qemu_gw[6] = {0x52, 0x55, 0x0A, 0x00, 0x02, 0x02};
|
||||||
arp_cache_insert(primary_if.gateway, qemu_gw);
|
arp_cache_insert(primary_if.gateway, qemu_gw);
|
||||||
|
|
||||||
printk(KERN_INFO "NET: eth0 configured (IP: 10.0.2.15, GW: 10.0.2.2, Mask: 255.255.255.0)\n");
|
printk(KERN_INFO "NET: eth0 configured (IP: 10.0.2.15, GW: 10.0.2.2, Mask: 255.255.255.0)\n");
|
||||||
|
|||||||
Reference in new issue
Block a user