[kitten] push by BrianK...@gmail.com - More updates to UDP, a few lwip configs, and a fix to eliminate segfau... on 2013-07-18 16:24 GMT

4 views
Skip to first unread message

kit...@googlecode.com

unread,
Jul 18, 2013, 12:25:15 PM7/18/13
to kitten-...@googlegroups.com
Revision: 3bbcebf11fb8
Branch: default
Author: Brian Kocoloski <bko...@sandia.gov>
Date: Thu Jul 18 09:24:28 2013
Log: More updates to UDP, a few lwip configs, and a fix to eliminate
segfaults in the e1000 driver
http://code.google.com/p/kitten/source/detail?r=3bbcebf11fb8

Modified:
/drivers/net/e1000/e1000.c
/include/lwip/lwipopts.h
/kernel/netdev.c
/net/api/sockets.c

=======================================
--- /drivers/net/e1000/e1000.c Tue Jul 9 16:03:24 2013
+++ /drivers/net/e1000/e1000.c Thu Jul 18 09:24:28 2013
@@ -576,14 +576,8 @@
netif->hwaddr[0], netif->hwaddr[1], netif->hwaddr[2],
netif->hwaddr[3], netif->hwaddr[4], netif->hwaddr[5]);

- // Register our interrupt handler
- int vector = ioapic_pcidev_vector(dev->pci_dev->cfg.bus,
dev->pci_dev->cfg.slot, 0);
- if (vector == -1) {
- printk(KERN_WARNING "E1000: Failed to find interrupt vector. Assuming
66!\n");
- vector = 66;
- }
- printk(KERN_INFO "E1000 IDT vector: %d\n", vector);
- irq_request(vector, &e1000_interrupt_handler, 0, "e1000", netif);
+ // Disable interrupts - will enable them when the card is ready
+ mmio_write32(E1000_REG_IMC, ~0);

// Initialize the rest of the Lightweight IP netif structure
netif->mtu = 1500;
@@ -614,6 +608,15 @@
e1000_tx_init(netif);

e1000_rx_enable(netif);
+
+ // Register our interrupt handler
+ int vector = ioapic_pcidev_vector(dev->pci_dev->cfg.bus,
dev->pci_dev->cfg.slot, 0);
+ if (vector == -1) {
+ printk(KERN_WARNING "E1000: Failed to find interrupt vector. Assuming
66!\n");
+ vector = 66;
+ }
+ printk(KERN_INFO "E1000 IDT vector: %d\n", vector);
+ irq_request(vector, &e1000_interrupt_handler, 0, "e1000", netif);

return 0;
}
=======================================
--- /include/lwip/lwipopts.h Thu Jul 11 13:42:41 2013
+++ /include/lwip/lwipopts.h Thu Jul 18 09:24:28 2013
@@ -8,6 +8,10 @@
#define LWIP_SO_SNDBUF 1
#define LWIP_SO_RCVBUF 1

+// BJK: Allow loopback
+#define LWIP_NETIF_LOOPBACK 1
+#define LWIP_NETIF_MAX_PBUFS 32
+
// BJK: These options are needed to support larger UDP messages. Tune as
needed.
// Note: Need invariant PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS
// Maximum outstanding messages in the mailbox. To be safe, message sizes
should be
=======================================
--- /kernel/netdev.c Thu Jul 11 13:42:41 2013
+++ /kernel/netdev.c Thu Jul 18 09:24:28 2013
@@ -460,11 +460,11 @@
int sockfd,
int level,
int optname,
- void * optval,
+ void * optval,
socklen_t * optlen
)
{
- int kint;
+ int kint;
int ret;

const int conn = lwip_from_fd( sockfd );
@@ -597,10 +597,21 @@
)
{
char databuf[len];
- uint8_t kbuf[sizeof(struct sockaddr)];
+ uint8_t kname[sizeof(struct sockaddr)];
+ socklen_t klen;
+
+ if (copy_from_user(&klen, addrlen, sizeof(socklen_t))) {
+ printk("%s: bad user address %p\n", __func__, (void*) addrlen);
+ return -EFAULT;
+ }
+
+ if (copy_from_user(kname, src_addr, klen)) {
+ printk("%s: bad user address %p\n", __func__, (void*) src_addr);
+ return -EFAULT;
+ }

int ret = lwip_recvfrom(lwip_from_fd(sockfd), databuf, len, flags,
- (struct sockaddr *)kbuf, addrlen);
+ (struct sockaddr *)kname, &klen);
if (ret == -1) {
ret = -lwip_lasterr(lwip_from_fd(sockfd));
} else {
@@ -609,15 +620,20 @@
return -EFAULT;
}

- if (translate_sockaddr_to_linux(kbuf, sizeof(struct sockaddr)) < 0) {
- printk("%s: bad kernel address %p translation\n", __func__, (void*)
kbuf);
+ if (translate_sockaddr_to_linux(kname, sizeof(struct sockaddr)) < 0) {
+ printk("%s: bad kernel address %p translation\n", __func__, (void*)
kname);
return -EFAULT;
}

- if (copy_to_user(src_addr, kbuf, *addrlen)) {
+ if (copy_to_user(src_addr, kname, klen)) {
printk("%s: bad user address %p\n", __func__, (void*) src_addr);
return -EFAULT;
}
+
+ if (copy_to_user(addrlen, &klen, sizeof(socklen_t))) {
+ printk("%s: bad user address %p\n", __func__, (void*) addrlen);
+ return -EFAULT;
+ }
}

return ret;
=======================================
--- /net/api/sockets.c Tue Jul 9 16:03:24 2013
+++ /net/api/sockets.c Thu Jul 18 09:24:28 2013
@@ -1582,6 +1582,9 @@
#if LWIP_SO_RCVBUF
case SO_RCVBUF:
#endif /* LWIP_SO_RCVBUF */
+#if LWIP_SO_SNDBUF
+ case SO_SNDBUF:
+#endif /* LWIP_SO_SNDBUF */
/* UNIMPL case SO_OOBINLINE: */
/* UNIMPL case SO_SNDBUF: */
/* UNIMPL case SO_RCVLOWAT: */
@@ -1856,6 +1859,12 @@
*(int *)optval = netconn_get_recvbufsize(sock->conn);
break;
#endif /* LWIP_SO_RCVBUF */
+#if LWIP_SO_SNDBUF
+ /* BJK: Currently, the SNDBUF size is the same as the RCVBUF size */
+ case SO_SNDBUF:
+ *(int *)optval = netconn_get_recvbufsize(sock->conn);
+ break;
+#endif /* LWIP_SO_SNDBUF */
#if LWIP_UDP
case SO_NO_CHECK:
*(int*)optval = (udp_flags(sock->conn->pcb.udp) &
UDP_FLAGS_NOCHKSUM) ? 1 : 0;
@@ -2026,6 +2035,9 @@
#if LWIP_SO_RCVBUF
case SO_RCVBUF:
#endif /* LWIP_SO_RCVBUF */
+#if LWIP_SO_SNDBUF
+ case SO_SNDBUF:
+#endif /* LWIP_SO_SNDBUF */
/* UNIMPL case SO_OOBINLINE: */
/* UNIMPL case SO_SNDBUF: */
/* UNIMPL case SO_RCVLOWAT: */
Reply all
Reply to author
Forward
0 new messages