Procházet zdrojové kódy

[tcpip] Pass through network device to transport layer protocols

NDP requires knowledge of the network device on which a packet was
received.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown před 11 roky
rodič
revize
6bf36f57a0
8 změnil soubory, kde provedl 26 přidání a 13 odebrání
  1. 5
    3
      src/include/ipxe/tcpip.h
  2. 4
    1
      src/net/icmp.c
  3. 1
    1
      src/net/icmpv6.c
  4. 1
    1
      src/net/ipv4.c
  5. 4
    3
      src/net/ipv6.c
  6. 2
    0
      src/net/tcp.c
  7. 5
    3
      src/net/tcpip.c
  8. 4
    1
      src/net/udp.c

+ 5
- 3
src/include/ipxe/tcpip.h Zobrazit soubor

@@ -69,6 +69,7 @@ struct tcpip_protocol {
69 69
          * Process received packet
70 70
          *
71 71
          * @v iobuf		I/O buffer
72
+	 * @v netdev		Network device
72 73
 	 * @v st_src		Partially-filled source address
73 74
 	 * @v st_dest		Partially-filled destination address
74 75
 	 * @v pshdr_csum	Pseudo-header checksum
@@ -76,7 +77,8 @@ struct tcpip_protocol {
76 77
          *
77 78
          * This method takes ownership of the I/O buffer.
78 79
          */
79
-        int ( * rx ) ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
80
+        int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
81
+		       struct sockaddr_tcpip *st_src,
80 82
 		       struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
81 83
         /** 
82 84
 	 * Transport-layer protocol number
@@ -128,8 +130,8 @@ struct tcpip_net_protocol {
128 130
 /** Declare a TCP/IP network-layer protocol */
129 131
 #define __tcpip_net_protocol __table_entry ( TCPIP_NET_PROTOCOLS, 01 )
130 132
 
131
-extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
132
-		      struct sockaddr_tcpip *st_src,
133
+extern int tcpip_rx ( struct io_buffer *iobuf, struct net_device *netdev,
134
+		      uint8_t tcpip_proto, struct sockaddr_tcpip *st_src,
133 135
 		      struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum );
134 136
 extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip,
135 137
 		      struct sockaddr_tcpip *st_src,

+ 4
- 1
src/net/icmp.c Zobrazit soubor

@@ -38,12 +38,15 @@ struct tcpip_protocol icmp_protocol __tcpip_protocol;
38 38
  * Process a received packet
39 39
  *
40 40
  * @v iobuf		I/O buffer
41
+ * @v netdev		Network device
41 42
  * @v st_src		Partially-filled source address
42 43
  * @v st_dest		Partially-filled destination address
43 44
  * @v pshdr_csum	Pseudo-header checksum
44 45
  * @ret rc		Return status code
45 46
  */
46
-static int icmp_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
47
+static int icmp_rx ( struct io_buffer *iobuf,
48
+		     struct net_device *netdev __unused,
49
+		     struct sockaddr_tcpip *st_src,
47 50
 		     struct sockaddr_tcpip *st_dest,
48 51
 		     uint16_t pshdr_csum __unused ) {
49 52
 	struct icmp_header *icmp = iobuf->data;

+ 1
- 1
src/net/icmpv6.c Zobrazit soubor

@@ -69,7 +69,7 @@ int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src __unuse
69 69
  * @v st_src	Source address
70 70
  * @v st_dest	Destination address
71 71
  */
72
-static int icmp6_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
72
+static int icmp6_rx ( struct io_buffer *iobuf, struct net_device *netdev __unused, struct sockaddr_tcpip *st_src,
73 73
 		      struct sockaddr_tcpip *st_dest, __unused uint16_t pshdr_csum ) {
74 74
 	struct icmp6_header *icmp6hdr = iobuf->data;
75 75
 

+ 1
- 1
src/net/ipv4.c Zobrazit soubor

@@ -469,7 +469,7 @@ static int ipv4_rx ( struct io_buffer *iobuf,
469 469
 	dest.sin.sin_addr = iphdr->dest;
470 470
 	pshdr_csum = ipv4_pshdr_chksum ( iobuf, TCPIP_EMPTY_CSUM );
471 471
 	iob_pull ( iobuf, hdrlen );
472
-	if ( ( rc = tcpip_rx ( iobuf, iphdr->protocol, &src.st,
472
+	if ( ( rc = tcpip_rx ( iobuf, netdev, iphdr->protocol, &src.st,
473 473
 			       &dest.st, pshdr_csum ) ) != 0 ) {
474 474
 		DBGC ( src.sin.sin_addr, "IPv4 received packet rejected by "
475 475
 		       "stack: %s\n", strerror ( rc ) );

+ 4
- 3
src/net/ipv6.c Zobrazit soubor

@@ -260,7 +260,8 @@ static int ipv6_tx ( struct io_buffer *iobuf,
260 260
  *
261 261
  * Refer http://www.iana.org/assignments/ipv6-parameters for the numbers
262 262
  */
263
-static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
263
+static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf,
264
+				  struct net_device *netdev, uint8_t nxt_hdr,
264 265
 		struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest ) {
265 266
 	switch ( nxt_hdr ) {
266 267
 	case IP6_HOPBYHOP: 
@@ -278,7 +279,7 @@ static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
278 279
 		return 0;
279 280
 	}
280 281
 	/* Next header is not a IPv6 extension header */
281
-	return tcpip_rx ( iobuf, nxt_hdr, src, dest, 0 /* fixme */ );
282
+	return tcpip_rx ( iobuf, netdev, nxt_hdr, src, dest, 0 /* fixme */ );
282 283
 }
283 284
 
284 285
 /**
@@ -344,7 +345,7 @@ static int ipv6_rx ( struct io_buffer *iobuf,
344 345
 	iob_pull ( iobuf, sizeof ( *ip6hdr ) );
345 346
 
346 347
 	/* Send it to the transport layer */
347
-	return ipv6_process_nxt_hdr ( iobuf, ip6hdr->nxt_hdr, &src.st, &dest.st );
348
+	return ipv6_process_nxt_hdr ( iobuf, netdev, ip6hdr->nxt_hdr, &src.st, &dest.st );
348 349
 
349 350
   drop:
350 351
 	DBG ( "Packet dropped\n" );

+ 2
- 0
src/net/tcp.c Zobrazit soubor

@@ -1115,12 +1115,14 @@ static void tcp_process_rx_queue ( struct tcp_connection *tcp ) {
1115 1115
  * Process received packet
1116 1116
  *
1117 1117
  * @v iobuf		I/O buffer
1118
+ * @v netdev		Network device
1118 1119
  * @v st_src		Partially-filled source address
1119 1120
  * @v st_dest		Partially-filled destination address
1120 1121
  * @v pshdr_csum	Pseudo-header checksum
1121 1122
  * @ret rc		Return status code
1122 1123
   */
1123 1124
 static int tcp_rx ( struct io_buffer *iobuf,
1125
+		    struct net_device *netdev __unused,
1124 1126
 		    struct sockaddr_tcpip *st_src,
1125 1127
 		    struct sockaddr_tcpip *st_dest __unused,
1126 1128
 		    uint16_t pshdr_csum ) {

+ 5
- 3
src/net/tcpip.c Zobrazit soubor

@@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
20 20
 /** Process a received TCP/IP packet
21 21
  *
22 22
  * @v iobuf		I/O buffer
23
+ * @v netdev		Network device
23 24
  * @v tcpip_proto	Transport-layer protocol number
24 25
  * @v st_src		Partially-filled source address
25 26
  * @v st_dest		Partially-filled destination address
@@ -32,8 +33,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
32 33
  * address family and the network-layer addresses, but leave the ports
33 34
  * and the rest of the structures as zero).
34 35
  */
35
-int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto, 
36
-	       struct sockaddr_tcpip *st_src,
36
+int tcpip_rx ( struct io_buffer *iobuf, struct net_device *netdev,
37
+	       uint8_t tcpip_proto, struct sockaddr_tcpip *st_src,
37 38
 	       struct sockaddr_tcpip *st_dest,
38 39
 	       uint16_t pshdr_csum ) {
39 40
 	struct tcpip_protocol *tcpip;
@@ -42,7 +43,8 @@ int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
42 43
 	for_each_table_entry ( tcpip, TCPIP_PROTOCOLS ) {
43 44
 		if ( tcpip->tcpip_proto == tcpip_proto ) {
44 45
 			DBG ( "TCP/IP received %s packet\n", tcpip->name );
45
-			return tcpip->rx ( iobuf, st_src, st_dest, pshdr_csum );
46
+			return tcpip->rx ( iobuf, netdev, st_src, st_dest,
47
+					   pshdr_csum );
46 48
 		}
47 49
 	}
48 50
 

+ 4
- 1
src/net/udp.c Zobrazit soubor

@@ -247,12 +247,15 @@ static struct udp_connection * udp_demux ( struct sockaddr_tcpip *local ) {
247 247
  * Process a received packet
248 248
  *
249 249
  * @v iobuf		I/O buffer
250
+ * @v netdev		Network device
250 251
  * @v st_src		Partially-filled source address
251 252
  * @v st_dest		Partially-filled destination address
252 253
  * @v pshdr_csum	Pseudo-header checksum
253 254
  * @ret rc		Return status code
254 255
  */
255
-static int udp_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
256
+static int udp_rx ( struct io_buffer *iobuf,
257
+		    struct net_device *netdev __unused,
258
+		    struct sockaddr_tcpip *st_src,
256 259
 		    struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum ) {
257 260
 	struct udp_header *udphdr = iobuf->data;
258 261
 	struct udp_connection *udp;

Načítá se…
Zrušit
Uložit