]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tcpip] Pass through network device to transport layer protocols
authorMichael Brown <mcb30@ipxe.org>
Sun, 1 Sep 2013 19:55:18 +0000 (20:55 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 3 Sep 2013 01:02:58 +0000 (02:02 +0100)
NDP requires knowledge of the network device on which a packet was
received.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/tcpip.h
src/net/icmp.c
src/net/icmpv6.c
src/net/ipv4.c
src/net/ipv6.c
src/net/tcp.c
src/net/tcpip.c
src/net/udp.c

index 0cc688a92e047405d60eca8160cb232e74f0e831..b2c559e22a8a0b477c514874830e00e57e1cd2cc 100644 (file)
@@ -69,6 +69,7 @@ struct tcpip_protocol {
          * Process received packet
          *
          * @v iobuf            I/O buffer
+        * @v netdev            Network device
         * @v st_src            Partially-filled source address
         * @v st_dest           Partially-filled destination address
         * @v pshdr_csum        Pseudo-header checksum
@@ -76,7 +77,8 @@ struct tcpip_protocol {
          *
          * This method takes ownership of the I/O buffer.
          */
-        int ( * rx ) ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
+        int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
+                      struct sockaddr_tcpip *st_src,
                       struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
         /** 
         * Transport-layer protocol number
@@ -128,8 +130,8 @@ struct tcpip_net_protocol {
 /** Declare a TCP/IP network-layer protocol */
 #define __tcpip_net_protocol __table_entry ( TCPIP_NET_PROTOCOLS, 01 )
 
-extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
-                     struct sockaddr_tcpip *st_src,
+extern int tcpip_rx ( struct io_buffer *iobuf, struct net_device *netdev,
+                     uint8_t tcpip_proto, struct sockaddr_tcpip *st_src,
                      struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
 extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip,
                      struct sockaddr_tcpip *st_src,
index 830d829244e950034003076cb8a60bf788ed19a0..6142b7483163f73774ccda3f7ffd33b0b5722e06 100644 (file)
@@ -38,12 +38,15 @@ struct tcpip_protocol icmp_protocol __tcpip_protocol;
  * Process a received packet
  *
  * @v iobuf            I/O buffer
+ * @v netdev           Network device
  * @v st_src           Partially-filled source address
  * @v st_dest          Partially-filled destination address
  * @v pshdr_csum       Pseudo-header checksum
  * @ret rc             Return status code
  */
-static int icmp_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
+static int icmp_rx ( struct io_buffer *iobuf,
+                    struct net_device *netdev __unused,
+                    struct sockaddr_tcpip *st_src,
                     struct sockaddr_tcpip *st_dest,
                     uint16_t pshdr_csum __unused ) {
        struct icmp_header *icmp = iobuf->data;
index 262ffc3f8cecf7b15dfb730c766553147fd5ab40..7242380627b6f4c452d2ee5e2b71dece37b56bf1 100644 (file)
@@ -69,7 +69,7 @@ int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src __unuse
  * @v st_src   Source address
  * @v st_dest  Destination address
  */
-static int icmp6_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
+static int icmp6_rx ( struct io_buffer *iobuf, struct net_device *netdev __unused, struct sockaddr_tcpip *st_src,
                      struct sockaddr_tcpip *st_dest, __unused uint16_t pshdr_csum ) {
        struct icmp6_header *icmp6hdr = iobuf->data;
 
index 106e8e795e0a2ed109d6b1ae920f2c1fed239cc9..bd318806234359af434916a42d318bb70831bd9e 100644 (file)
@@ -469,7 +469,7 @@ static int ipv4_rx ( struct io_buffer *iobuf,
        dest.sin.sin_addr = iphdr->dest;
        pshdr_csum = ipv4_pshdr_chksum ( iobuf, TCPIP_EMPTY_CSUM );
        iob_pull ( iobuf, hdrlen );
-       if ( ( rc = tcpip_rx ( iobuf, iphdr->protocol, &src.st,
+       if ( ( rc = tcpip_rx ( iobuf, netdev, iphdr->protocol, &src.st,
                               &dest.st, pshdr_csum ) ) != 0 ) {
                DBGC ( src.sin.sin_addr, "IPv4 received packet rejected by "
                       "stack: %s\n", strerror ( rc ) );
index d76e59cbdf39d2757540fd2449c6c52737cc5de7..077118df691f842cbf867e0f5177f6f0f3a027fa 100644 (file)
@@ -260,7 +260,8 @@ static int ipv6_tx ( struct io_buffer *iobuf,
  *
  * Refer http://www.iana.org/assignments/ipv6-parameters for the numbers
  */
-static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
+static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf,
+                                 struct net_device *netdev, uint8_t nxt_hdr,
                struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest ) {
        switch ( nxt_hdr ) {
        case IP6_HOPBYHOP: 
@@ -278,7 +279,7 @@ static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
                return 0;
        }
        /* Next header is not a IPv6 extension header */
-       return tcpip_rx ( iobuf, nxt_hdr, src, dest, 0 /* fixme */ );
+       return tcpip_rx ( iobuf, netdev, nxt_hdr, src, dest, 0 /* fixme */ );
 }
 
 /**
@@ -344,7 +345,7 @@ static int ipv6_rx ( struct io_buffer *iobuf,
        iob_pull ( iobuf, sizeof ( *ip6hdr ) );
 
        /* Send it to the transport layer */
-       return ipv6_process_nxt_hdr ( iobuf, ip6hdr->nxt_hdr, &src.st, &dest.st );
+       return ipv6_process_nxt_hdr ( iobuf, netdev, ip6hdr->nxt_hdr, &src.st, &dest.st );
 
   drop:
        DBG ( "Packet dropped\n" );
index 0e18c831dd6a79b04c47a2a4c4c41bc4506ed8b4..1e1968a0ae04f29267e5ed28792d73f090cf4129 100644 (file)
@@ -1115,12 +1115,14 @@ static void tcp_process_rx_queue ( struct tcp_connection *tcp ) {
  * Process received packet
  *
  * @v iobuf            I/O buffer
+ * @v netdev           Network device
  * @v st_src           Partially-filled source address
  * @v st_dest          Partially-filled destination address
  * @v pshdr_csum       Pseudo-header checksum
  * @ret rc             Return status code
   */
 static int tcp_rx ( struct io_buffer *iobuf,
+                   struct net_device *netdev __unused,
                    struct sockaddr_tcpip *st_src,
                    struct sockaddr_tcpip *st_dest __unused,
                    uint16_t pshdr_csum ) {
index 721a4e4837304cf9ca520a1159e37d1f2c7050d8..0e4671444f7f2a9779c09eb4d9096eb7d9489b6f 100644 (file)
@@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 /** Process a received TCP/IP packet
  *
  * @v iobuf            I/O buffer
+ * @v netdev           Network device
  * @v tcpip_proto      Transport-layer protocol number
  * @v st_src           Partially-filled source address
  * @v st_dest          Partially-filled destination address
@@ -32,8 +33,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
  * address family and the network-layer addresses, but leave the ports
  * and the rest of the structures as zero).
  */
-int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto, 
-              struct sockaddr_tcpip *st_src,
+int tcpip_rx ( struct io_buffer *iobuf, struct net_device *netdev,
+              uint8_t tcpip_proto, struct sockaddr_tcpip *st_src,
               struct sockaddr_tcpip *st_dest,
               uint16_t pshdr_csum ) {
        struct tcpip_protocol *tcpip;
@@ -42,7 +43,8 @@ int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
        for_each_table_entry ( tcpip, TCPIP_PROTOCOLS ) {
                if ( tcpip->tcpip_proto == tcpip_proto ) {
                        DBG ( "TCP/IP received %s packet\n", tcpip->name );
-                       return tcpip->rx ( iobuf, st_src, st_dest, pshdr_csum );
+                       return tcpip->rx ( iobuf, netdev, st_src, st_dest,
+                                          pshdr_csum );
                }
        }
 
index edc7488a36362c63e6bf0a49cc51fb2790cdfe54..596f242a9e5723f0e45ee0ed6e5bdd7b818cdc7f 100644 (file)
@@ -247,12 +247,15 @@ static struct udp_connection * udp_demux ( struct sockaddr_tcpip *local ) {
  * Process a received packet
  *
  * @v iobuf            I/O buffer
+ * @v netdev           Network device
  * @v st_src           Partially-filled source address
  * @v st_dest          Partially-filled destination address
  * @v pshdr_csum       Pseudo-header checksum
  * @ret rc             Return status code
  */
-static int udp_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
+static int udp_rx ( struct io_buffer *iobuf,
+                   struct net_device *netdev __unused,
+                   struct sockaddr_tcpip *st_src,
                    struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum ) {
        struct udp_header *udphdr = iobuf->data;
        struct udp_connection *udp;