aboutsummaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2014-10-28 16:09:17 +0530
committerNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2014-10-29 17:02:08 +0530
commit1f33e4f29e8cf4ba14e75d8fa37fd9ba0ea09c53 (patch)
treef84498b942fa111803bf223dd1389b12132dcb6b /clients
parentb931c7bc10a3c29a8ca0e693d4dfb94f17311451 (diff)
downloadSLOF-1f33e4f29e8cf4ba14e75d8fa37fd9ba0ea09c53.zip
SLOF-1f33e4f29e8cf4ba14e75d8fa37fd9ba0ea09c53.tar.gz
SLOF-1f33e4f29e8cf4ba14e75d8fa37fd9ba0ea09c53.tar.bz2
ipv4: Fix send packet across a subnet
The send packet code does understand that the IP is not part of the current network and needs to use the router. And then tries to get the MAC address of the router IP from arp cache, that fails. This is becuase there was no ARP Request send for the router IP. So in case when there is router involved, send arp request for the router IP and after the reply, we have the router mac cached to communicate with. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Diffstat (limited to 'clients')
-rw-r--r--clients/net-snk/app/netlib/ipv4.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/clients/net-snk/app/netlib/ipv4.c b/clients/net-snk/app/netlib/ipv4.c
index 1d5dd73..8185de5 100644
--- a/clients/net-snk/app/netlib/ipv4.c
+++ b/clients/net-snk/app/netlib/ipv4.c
@@ -428,6 +428,7 @@ send_ipv4(int fd, void* buffer, int len)
arp_entry_t *arp_entry = 0;
struct iphdr *ip;
const uint8_t *mac_addr = 0;
+ uint32_t ip_dst = 0;
if(len + sizeof(struct ethhdr) > ETH_MTU_SIZE)
return -1;
@@ -459,6 +460,7 @@ send_ipv4(int fd, void* buffer, int len)
fill_udp_checksum(ip);
}
+ ip_dst = ip->ip_dst;
// Check if the MAC address is already cached
if(~ip->ip_dst == 0
|| ( ((~subnet_mask) & ip->ip_dst) == ~subnet_mask &&
@@ -475,8 +477,10 @@ send_ipv4(int fd, void* buffer, int len)
if((subnet_mask & own_ip) == (subnet_mask & ip->ip_dst))
arp_entry = lookup_mac_addr(ip->ip_dst);
// if not then we need to know the router's IP address
- else
+ else {
+ ip_dst = router_ip;
arp_entry = lookup_mac_addr(router_ip);
+ }
if(arp_entry && memcmp(arp_entry->mac_addr, null_mac_addr, 6) != 0)
mac_addr = arp_entry->mac_addr;
}
@@ -484,7 +488,7 @@ send_ipv4(int fd, void* buffer, int len)
// If we could not resolv the MAC address by our own...
if(!mac_addr) {
// send the ARP request
- arp_send_request(fd, ip->ip_dst);
+ arp_send_request(fd, ip_dst);
// drop the current packet if there is already a ARP request pending
if(arp_entry)
@@ -500,9 +504,9 @@ send_ipv4(int fd, void* buffer, int len)
// store the packet to be send if the ARP reply is received
arp_entry->pkt_pending = 1;
- arp_entry->ipv4_addr = ip->ip_dst;
+ arp_entry->ipv4_addr = ip_dst;
memset(arp_entry->mac_addr, 0, 6);
- pending_pkt.ipv4_addr = ip->ip_dst;
+ pending_pkt.ipv4_addr = ip_dst;
memset(pending_pkt.mac_addr, 0, 6);
fill_ethhdr (pending_pkt.eth_frame, htons(ETHERTYPE_IP),
get_mac_address(), null_mac_addr);