Browse Source

[netdevice] Allow link layer to report broadcast/multicast packets via pull()

Allow the link layer to directly report whether or not a packet is
multicast or broadcast at the time of calling pull(), rather than
relying on heuristics to determine this at a later stage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
a667bf044a

+ 7
- 7
src/arch/i386/interface/pxe/pxe_undi.c View File

652
 	const void *ll_dest;
652
 	const void *ll_dest;
653
 	const void *ll_source;
653
 	const void *ll_source;
654
 	uint16_t net_proto;
654
 	uint16_t net_proto;
655
+	unsigned int flags;
655
 	size_t ll_hlen;
656
 	size_t ll_hlen;
656
 	struct net_protocol *net_protocol;
657
 	struct net_protocol *net_protocol;
657
 	unsigned int prottype;
658
 	unsigned int prottype;
753
 		/* Strip link-layer header */
754
 		/* Strip link-layer header */
754
 		ll_protocol = pxe_netdev->ll_protocol;
755
 		ll_protocol = pxe_netdev->ll_protocol;
755
 		if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
756
 		if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
756
-						&ll_source, &net_proto )) !=0){
757
+						&ll_source, &net_proto,
758
+						&flags ) ) != 0 ) {
757
 			/* Assume unknown net_proto and no ll_source */
759
 			/* Assume unknown net_proto and no ll_source */
758
 			net_proto = 0;
760
 			net_proto = 0;
759
 			ll_source = NULL;
761
 			ll_source = NULL;
788
 		undi_isr->Frame.segment = rm_ds;
790
 		undi_isr->Frame.segment = rm_ds;
789
 		undi_isr->Frame.offset = __from_data16 ( basemem_packet );
791
 		undi_isr->Frame.offset = __from_data16 ( basemem_packet );
790
 		undi_isr->ProtType = prottype;
792
 		undi_isr->ProtType = prottype;
791
-		if ( memcmp ( ll_dest, pxe_netdev->ll_addr,
792
-			      ll_protocol->ll_addr_len ) == 0 ) {
793
-			undi_isr->PktType = P_DIRECTED;
794
-		} else if ( memcmp ( ll_dest, pxe_netdev->ll_broadcast,
795
-				     ll_protocol->ll_addr_len ) == 0 ) {
793
+		if ( flags & LL_BROADCAST ) {
796
 			undi_isr->PktType = P_BROADCAST;
794
 			undi_isr->PktType = P_BROADCAST;
797
-		} else {
795
+		} else if ( flags & LL_MULTICAST ) {
798
 			undi_isr->PktType = P_MULTICAST;
796
 			undi_isr->PktType = P_MULTICAST;
797
+		} else {
798
+			undi_isr->PktType = P_DIRECTED;
799
 		}
799
 		}
800
 		DBGC2 ( &pxenv_undi_isr, " %04x:%04x+%x(%x) %s hlen %d",
800
 		DBGC2 ( &pxenv_undi_isr, " %04x:%04x+%x(%x) %s hlen %d",
801
 			undi_isr->Frame.segment, undi_isr->Frame.offset,
801
 			undi_isr->Frame.segment, undi_isr->Frame.offset,

+ 4
- 1
src/drivers/net/ipoib.c View File

224
  * @ret ll_dest		Link-layer destination address
224
  * @ret ll_dest		Link-layer destination address
225
  * @ret ll_source	Source link-layer address
225
  * @ret ll_source	Source link-layer address
226
  * @ret net_proto	Network-layer protocol, in network-byte order
226
  * @ret net_proto	Network-layer protocol, in network-byte order
227
+ * @ret flags		Packet flags
227
  * @ret rc		Return status code
228
  * @ret rc		Return status code
228
  */
229
  */
229
 static int ipoib_pull ( struct net_device *netdev,
230
 static int ipoib_pull ( struct net_device *netdev,
230
 			struct io_buffer *iobuf, const void **ll_dest,
231
 			struct io_buffer *iobuf, const void **ll_dest,
231
-			const void **ll_source, uint16_t *net_proto ) {
232
+			const void **ll_source, uint16_t *net_proto,
233
+			unsigned int *flags ) {
232
 	struct ipoib_device *ipoib = netdev->priv;
234
 	struct ipoib_device *ipoib = netdev->priv;
233
 	struct ipoib_hdr *ipoib_hdr = iobuf->data;
235
 	struct ipoib_hdr *ipoib_hdr = iobuf->data;
234
 	struct ipoib_peer *dest;
236
 	struct ipoib_peer *dest;
255
 	*ll_dest = ( dest ? &dest->mac : &ipoib->broadcast );
257
 	*ll_dest = ( dest ? &dest->mac : &ipoib->broadcast );
256
 	*ll_source = ( source ? &source->mac : &ipoib->broadcast );
258
 	*ll_source = ( source ? &source->mac : &ipoib->broadcast );
257
 	*net_proto = ipoib_hdr->proto;
259
 	*net_proto = ipoib_hdr->proto;
260
+	*flags = ( ( *ll_dest == &ipoib->broadcast ) ? LL_BROADCAST : 0 );
258
 
261
 
259
 	return 0;
262
 	return 0;
260
 }
263
 }

+ 19
- 9
src/include/ipxe/netdevice.h View File

66
 	/**
66
 	/**
67
 	 * Process received packet
67
 	 * Process received packet
68
 	 *
68
 	 *
69
-	 * @v iobuf	I/O buffer
70
-	 * @v netdev	Network device
71
-	 * @v ll_dest	Link-layer destination address
72
-	 * @v ll_source	Link-layer source address
69
+	 * @v iobuf		I/O buffer
70
+	 * @v netdev		Network device
71
+	 * @v ll_dest		Link-layer destination address
72
+	 * @v ll_source		Link-layer source address
73
+	 * @v flags		Packet flags
74
+	 * @ret rc		Return status code
73
 	 *
75
 	 *
74
 	 * This method takes ownership of the I/O buffer.
76
 	 * This method takes ownership of the I/O buffer.
75
 	 */
77
 	 */
76
 	int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
78
 	int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
77
-		       const void *ll_dest, const void *ll_source );
79
+		       const void *ll_dest, const void *ll_source,
80
+		       unsigned int flags );
78
 	/**
81
 	/**
79
 	 * Transcribe network-layer address
82
 	 * Transcribe network-layer address
80
 	 *
83
 	 *
81
-	 * @v net_addr	Network-layer address
82
-	 * @ret string	Human-readable transcription of address
84
+	 * @v net_addr		Network-layer address
85
+	 * @ret string		Human-readable transcription of address
83
 	 *
86
 	 *
84
 	 * This method should convert the network-layer address into a
87
 	 * This method should convert the network-layer address into a
85
 	 * human-readable format (e.g. dotted quad notation for IPv4).
88
 	 * human-readable format (e.g. dotted quad notation for IPv4).
97
 	uint8_t net_addr_len;
100
 	uint8_t net_addr_len;
98
 };
101
 };
99
 
102
 
103
+/** Packet is a multicast (including broadcast) packet */
104
+#define LL_MULTICAST 0x0001
105
+
106
+/** Packet is a broadcast packet */
107
+#define LL_BROADCAST 0x0002
108
+
100
 /**
109
 /**
101
  * A link-layer protocol
110
  * A link-layer protocol
102
  *
111
  *
125
 	 * @ret ll_dest		Link-layer destination address
134
 	 * @ret ll_dest		Link-layer destination address
126
 	 * @ret ll_source	Source link-layer address
135
 	 * @ret ll_source	Source link-layer address
127
 	 * @ret net_proto	Network-layer protocol, in network-byte order
136
 	 * @ret net_proto	Network-layer protocol, in network-byte order
137
+	 * @ret flags		Packet flags
128
 	 * @ret rc		Return status code
138
 	 * @ret rc		Return status code
129
 	 */
139
 	 */
130
 	int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
140
 	int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
131
 			 const void **ll_dest, const void **ll_source,
141
 			 const void **ll_dest, const void **ll_source,
132
-			 uint16_t *net_proto );
142
+			 uint16_t *net_proto, unsigned int *flags );
133
 	/**
143
 	/**
134
 	 * Initialise link-layer address
144
 	 * Initialise link-layer address
135
 	 *
145
 	 *
611
 		    const void *ll_source );
621
 		    const void *ll_source );
612
 extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
622
 extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
613
 		    uint16_t net_proto, const void *ll_dest,
623
 		    uint16_t net_proto, const void *ll_dest,
614
-		    const void *ll_source );
624
+		    const void *ll_source, unsigned int flags );
615
 extern void net_poll ( void );
625
 extern void net_poll ( void );
616
 
626
 
617
 /**
627
 /**

+ 3
- 1
src/interface/efi/efi_snp.c View File

658
 	const void *iob_ll_dest;
658
 	const void *iob_ll_dest;
659
 	const void *iob_ll_src;
659
 	const void *iob_ll_src;
660
 	uint16_t iob_net_proto;
660
 	uint16_t iob_net_proto;
661
+	unsigned int iob_flags;
661
 	int rc;
662
 	int rc;
662
 	EFI_STATUS efirc;
663
 	EFI_STATUS efirc;
663
 
664
 
682
 
683
 
683
 	/* Attempt to decode link-layer header */
684
 	/* Attempt to decode link-layer header */
684
 	if ( ( rc = ll_protocol->pull ( snpdev->netdev, iobuf, &iob_ll_dest,
685
 	if ( ( rc = ll_protocol->pull ( snpdev->netdev, iobuf, &iob_ll_dest,
685
-					&iob_ll_src, &iob_net_proto ) ) != 0 ){
686
+					&iob_ll_src, &iob_net_proto,
687
+					&iob_flags ) ) != 0 ) {
686
 		DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
688
 		DBGC ( snpdev, "SNPDEV %p could not parse header: %s\n",
687
 		       snpdev, strerror ( rc ) );
689
 		       snpdev, strerror ( rc ) );
688
 		efirc = RC_TO_EFIRC ( rc );
690
 		efirc = RC_TO_EFIRC ( rc );

+ 8
- 2
src/net/80211/net80211.c View File

135
 			      const void *ll_source, uint16_t net_proto );
135
 			      const void *ll_source, uint16_t net_proto );
136
 static int net80211_ll_pull ( struct net_device *netdev,
136
 static int net80211_ll_pull ( struct net_device *netdev,
137
 			      struct io_buffer *iobuf, const void **ll_dest,
137
 			      struct io_buffer *iobuf, const void **ll_dest,
138
-			      const void **ll_source, uint16_t * net_proto );
138
+			      const void **ll_source, uint16_t * net_proto,
139
+			      unsigned int *flags );
139
 /** @} */
140
 /** @} */
140
 
141
 
141
 /**
142
 /**
529
  * @ret ll_dest		Link-layer destination address
530
  * @ret ll_dest		Link-layer destination address
530
  * @ret ll_source	Link-layer source
531
  * @ret ll_source	Link-layer source
531
  * @ret net_proto	Network-layer protocol, in network byte order
532
  * @ret net_proto	Network-layer protocol, in network byte order
533
+ * @ret flags		Packet flags
532
  * @ret rc		Return status code
534
  * @ret rc		Return status code
533
  *
535
  *
534
  * This expects and removes both the 802.11 frame header and the 802.2
536
  * This expects and removes both the 802.11 frame header and the 802.2
537
 static int net80211_ll_pull ( struct net_device *netdev __unused,
539
 static int net80211_ll_pull ( struct net_device *netdev __unused,
538
 			      struct io_buffer *iobuf,
540
 			      struct io_buffer *iobuf,
539
 			      const void **ll_dest, const void **ll_source,
541
 			      const void **ll_dest, const void **ll_source,
540
-			      uint16_t * net_proto )
542
+			      uint16_t * net_proto, unsigned int *flags )
541
 {
543
 {
542
 	struct ieee80211_frame *hdr = iobuf->data;
544
 	struct ieee80211_frame *hdr = iobuf->data;
543
 	struct ieee80211_llc_snap_header *lhdr =
545
 	struct ieee80211_llc_snap_header *lhdr =
586
 	*ll_dest = hdr->addr1;
588
 	*ll_dest = hdr->addr1;
587
 	*ll_source = hdr->addr3;
589
 	*ll_source = hdr->addr3;
588
 	*net_proto = lhdr->ethertype;
590
 	*net_proto = lhdr->ethertype;
591
+	*flags = ( ( is_multicast_ether_addr ( hdr->addr1 ) ?
592
+		     LL_MULTICAST : 0 ) |
593
+		   ( is_broadcast_ether_addr ( hdr->addr1 ) ?
594
+		     LL_BROADCAST : 0 ) );
589
 	return 0;
595
 	return 0;
590
 }
596
 }
591
 
597
 

+ 3
- 2
src/net/aoe.c View File

906
  * @v netdev		Network device
906
  * @v netdev		Network device
907
  * @v ll_dest		Link-layer destination address
907
  * @v ll_dest		Link-layer destination address
908
  * @v ll_source		Link-layer source address
908
  * @v ll_source		Link-layer source address
909
+ * @v flags		Packet flags
909
  * @ret rc		Return status code
910
  * @ret rc		Return status code
910
- *
911
  */
911
  */
912
 static int aoe_rx ( struct io_buffer *iobuf,
912
 static int aoe_rx ( struct io_buffer *iobuf,
913
 		    struct net_device *netdev __unused,
913
 		    struct net_device *netdev __unused,
914
 		    const void *ll_dest __unused,
914
 		    const void *ll_dest __unused,
915
-		    const void *ll_source ) {
915
+		    const void *ll_source,
916
+		    unsigned int flags __unused ) {
916
 	struct aoehdr *aoehdr = iobuf->data;
917
 	struct aoehdr *aoehdr = iobuf->data;
917
 	struct aoe_command *aoecmd;
918
 	struct aoe_command *aoecmd;
918
 	int rc;
919
 	int rc;

+ 3
- 1
src/net/arp.c View File

186
  * @v iobuf		I/O buffer
186
  * @v iobuf		I/O buffer
187
  * @v netdev		Network device
187
  * @v netdev		Network device
188
  * @v ll_source		Link-layer source address
188
  * @v ll_source		Link-layer source address
189
+ * @v flags		Packet flags
189
  * @ret rc		Return status code
190
  * @ret rc		Return status code
190
  *
191
  *
191
  * This handles ARP requests and responses as detailed in RFC826.  The
192
  * This handles ARP requests and responses as detailed in RFC826.  The
196
  */
197
  */
197
 static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
198
 static int arp_rx ( struct io_buffer *iobuf, struct net_device *netdev,
198
 		    const void *ll_dest __unused,
199
 		    const void *ll_dest __unused,
199
-		    const void *ll_source __unused ) {
200
+		    const void *ll_source __unused,
201
+		    unsigned int flags __unused ) {
200
 	struct arphdr *arphdr = iobuf->data;
202
 	struct arphdr *arphdr = iobuf->data;
201
 	struct arp_net_protocol *arp_net_protocol;
203
 	struct arp_net_protocol *arp_net_protocol;
202
 	struct net_protocol *net_protocol;
204
 	struct net_protocol *net_protocol;

+ 3
- 1
src/net/eapol.c View File

38
  * @v netdev	Network device
38
  * @v netdev	Network device
39
  * @v ll_dest	Link-layer destination address
39
  * @v ll_dest	Link-layer destination address
40
  * @v ll_source	Link-layer source address
40
  * @v ll_source	Link-layer source address
41
+ * @v flags	Packet flags
41
  *
42
  *
42
  * This function takes ownership of the I/O buffer passed to it.
43
  * This function takes ownership of the I/O buffer passed to it.
43
  */
44
  */
44
 static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
45
 static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
45
-		      const void *ll_dest, const void *ll_source ) {
46
+		      const void *ll_dest, const void *ll_source,
47
+		      unsigned int flags __unused ) {
46
 	struct eapol_frame *eapol = iob->data;
48
 	struct eapol_frame *eapol = iob->data;
47
 	struct eapol_handler *handler;
49
 	struct eapol_handler *handler;
48
 
50
 

+ 3
- 1
src/net/eth_slow.c View File

234
  * @v netdev		Network device
234
  * @v netdev		Network device
235
  * @v ll_dest		Link-layer destination address
235
  * @v ll_dest		Link-layer destination address
236
  * @v ll_source		Link-layer source address
236
  * @v ll_source		Link-layer source address
237
+ * @v flags		Packet flags
237
  * @ret rc		Return status code
238
  * @ret rc		Return status code
238
  */
239
  */
239
 static int eth_slow_rx ( struct io_buffer *iobuf,
240
 static int eth_slow_rx ( struct io_buffer *iobuf,
240
 			 struct net_device *netdev,
241
 			 struct net_device *netdev,
241
 			 const void *ll_dest __unused,
242
 			 const void *ll_dest __unused,
242
-			 const void *ll_source __unused ) {
243
+			 const void *ll_source __unused,
244
+			 unsigned int flags __unused ) {
243
 	union eth_slow_packet *eth_slow = iobuf->data;
245
 	union eth_slow_packet *eth_slow = iobuf->data;
244
 
246
 
245
 	/* Sanity checks */
247
 	/* Sanity checks */

+ 7
- 1
src/net/ethernet.c View File

71
  * @ret ll_dest		Link-layer destination address
71
  * @ret ll_dest		Link-layer destination address
72
  * @ret ll_source	Source link-layer address
72
  * @ret ll_source	Source link-layer address
73
  * @ret net_proto	Network-layer protocol, in network-byte order
73
  * @ret net_proto	Network-layer protocol, in network-byte order
74
+ * @ret flags		Packet flags
74
  * @ret rc		Return status code
75
  * @ret rc		Return status code
75
  */
76
  */
76
 static int eth_pull ( struct net_device *netdev __unused, 
77
 static int eth_pull ( struct net_device *netdev __unused, 
77
 		      struct io_buffer *iobuf, const void **ll_dest,
78
 		      struct io_buffer *iobuf, const void **ll_dest,
78
-		      const void **ll_source, uint16_t *net_proto ) {
79
+		      const void **ll_source, uint16_t *net_proto,
80
+		      unsigned int *flags ) {
79
 	struct ethhdr *ethhdr = iobuf->data;
81
 	struct ethhdr *ethhdr = iobuf->data;
80
 
82
 
81
 	/* Sanity check */
83
 	/* Sanity check */
92
 	*ll_dest = ethhdr->h_dest;
94
 	*ll_dest = ethhdr->h_dest;
93
 	*ll_source = ethhdr->h_source;
95
 	*ll_source = ethhdr->h_source;
94
 	*net_proto = ethhdr->h_protocol;
96
 	*net_proto = ethhdr->h_protocol;
97
+	*flags = ( ( is_multicast_ether_addr ( ethhdr->h_dest ) ?
98
+		     LL_MULTICAST : 0 ) |
99
+		   ( is_broadcast_ether_addr ( ethhdr->h_dest ) ?
100
+		     LL_BROADCAST : 0 ) );
95
 
101
 
96
 	return 0;
102
 	return 0;
97
 }
103
 }

+ 6
- 2
src/net/fcoe.c View File

331
  * @v netdev		Network device
331
  * @v netdev		Network device
332
  * @v ll_dest		Link-layer destination address
332
  * @v ll_dest		Link-layer destination address
333
  * @v ll_source		Link-layer source address
333
  * @v ll_source		Link-layer source address
334
+ * @v flags		Packet flags
334
  * @ret rc		Return status code
335
  * @ret rc		Return status code
335
  */
336
  */
336
 static int fcoe_rx ( struct io_buffer *iobuf, struct net_device *netdev,
337
 static int fcoe_rx ( struct io_buffer *iobuf, struct net_device *netdev,
337
-		     const void *ll_dest, const void *ll_source ) {
338
+		     const void *ll_dest, const void *ll_source,
339
+		     unsigned int flags __unused ) {
338
 	struct fcoe_header *fcoehdr;
340
 	struct fcoe_header *fcoehdr;
339
 	struct fcoe_footer *fcoeftr;
341
 	struct fcoe_footer *fcoeftr;
340
 	struct fcoe_port *fcoe;
342
 	struct fcoe_port *fcoe;
924
  * @v netdev		Network device
926
  * @v netdev		Network device
925
  * @v ll_dest		Link-layer destination address
927
  * @v ll_dest		Link-layer destination address
926
  * @v ll_source		Link-layer source address
928
  * @v ll_source		Link-layer source address
929
+ * @v flags		Packet flags
927
  * @ret rc		Return status code
930
  * @ret rc		Return status code
928
  */
931
  */
929
 static int fcoe_fip_rx ( struct io_buffer *iobuf,
932
 static int fcoe_fip_rx ( struct io_buffer *iobuf,
930
 			 struct net_device *netdev,
933
 			 struct net_device *netdev,
931
 			 const void *ll_dest,
934
 			 const void *ll_dest,
932
-			 const void *ll_source __unused ) {
935
+			 const void *ll_source __unused,
936
+			 unsigned int flags __unused ) {
933
 	struct fip_header *fiphdr = iobuf->data;
937
 	struct fip_header *fiphdr = iobuf->data;
934
 	struct fip_descriptors descs;
938
 	struct fip_descriptors descs;
935
 	struct fip_handler *handler;
939
 	struct fip_handler *handler;

+ 8
- 5
src/net/ipv4.c View File

381
 /**
381
 /**
382
  * Process incoming packets
382
  * Process incoming packets
383
  *
383
  *
384
- * @v iobuf	I/O buffer
385
- * @v netdev	Network device
386
- * @v ll_dest	Link-layer destination address
387
- * @v ll_source	Link-layer destination source
384
+ * @v iobuf		I/O buffer
385
+ * @v netdev		Network device
386
+ * @v ll_dest		Link-layer destination address
387
+ * @v ll_source		Link-layer destination source
388
+ * @v flags		Packet flags
389
+ * @ret rc		Return status code
388
  *
390
  *
389
  * This function expects an IP4 network datagram. It processes the headers 
391
  * This function expects an IP4 network datagram. It processes the headers 
390
  * and sends it to the transport layer.
392
  * and sends it to the transport layer.
392
 static int ipv4_rx ( struct io_buffer *iobuf,
394
 static int ipv4_rx ( struct io_buffer *iobuf,
393
 		     struct net_device *netdev __unused,
395
 		     struct net_device *netdev __unused,
394
 		     const void *ll_dest __unused,
396
 		     const void *ll_dest __unused,
395
-		     const void *ll_source __unused ) {
397
+		     const void *ll_source __unused,
398
+		     unsigned int flags __unused ) {
396
 	struct iphdr *iphdr = iobuf->data;
399
 	struct iphdr *iphdr = iobuf->data;
397
 	size_t hdrlen;
400
 	size_t hdrlen;
398
 	size_t len;
401
 	size_t len;

+ 3
- 1
src/net/ipv6.c View File

288
  * @v netdev		Network device
288
  * @v netdev		Network device
289
  * @v ll_dest		Link-layer destination address
289
  * @v ll_dest		Link-layer destination address
290
  * @v ll_source		Link-layer source address
290
  * @v ll_source		Link-layer source address
291
+ * @v flags		Packet flags
291
  *
292
  *
292
  * This function processes a IPv6 packet
293
  * This function processes a IPv6 packet
293
  */
294
  */
294
 static int ipv6_rx ( struct io_buffer *iobuf,
295
 static int ipv6_rx ( struct io_buffer *iobuf,
295
 		     __unused struct net_device *netdev,
296
 		     __unused struct net_device *netdev,
296
 		     __unused const void *ll_dest,
297
 		     __unused const void *ll_dest,
297
-		     __unused const void *ll_source ) {
298
+		     __unused const void *ll_source,
299
+		     __unused unsigned int flags ) {
298
 
300
 
299
 	struct ip6_header *ip6hdr = iobuf->data;
301
 	struct ip6_header *ip6hdr = iobuf->data;
300
 	union {
302
 	union {

+ 8
- 4
src/net/netdevice.c View File

678
  * @v net_proto		Network-layer protocol, in network-byte order
678
  * @v net_proto		Network-layer protocol, in network-byte order
679
  * @v ll_dest		Destination link-layer address
679
  * @v ll_dest		Destination link-layer address
680
  * @v ll_source		Source link-layer address
680
  * @v ll_source		Source link-layer address
681
+ * @v flags		Packet flags
681
  * @ret rc		Return status code
682
  * @ret rc		Return status code
682
  */
683
  */
683
 int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
684
 int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
684
-	     uint16_t net_proto, const void *ll_dest, const void *ll_source ) {
685
+	     uint16_t net_proto, const void *ll_dest, const void *ll_source,
686
+	     unsigned int flags ) {
685
 	struct net_protocol *net_protocol;
687
 	struct net_protocol *net_protocol;
686
 
688
 
687
 	/* Hand off to network-layer protocol, if any */
689
 	/* Hand off to network-layer protocol, if any */
688
 	for_each_table_entry ( net_protocol, NET_PROTOCOLS ) {
690
 	for_each_table_entry ( net_protocol, NET_PROTOCOLS ) {
689
 		if ( net_protocol->net_proto == net_proto )
691
 		if ( net_protocol->net_proto == net_proto )
690
 			return net_protocol->rx ( iobuf, netdev, ll_dest,
692
 			return net_protocol->rx ( iobuf, netdev, ll_dest,
691
-						  ll_source );
693
+						  ll_source, flags );
692
 	}
694
 	}
693
 
695
 
694
 	DBGC ( netdev, "NETDEV %s unknown network protocol %04x\n",
696
 	DBGC ( netdev, "NETDEV %s unknown network protocol %04x\n",
710
 	const void *ll_dest;
712
 	const void *ll_dest;
711
 	const void *ll_source;
713
 	const void *ll_source;
712
 	uint16_t net_proto;
714
 	uint16_t net_proto;
715
+	unsigned int flags;
713
 	int rc;
716
 	int rc;
714
 
717
 
715
 	/* Poll and process each network device */
718
 	/* Poll and process each network device */
743
 			ll_protocol = netdev->ll_protocol;
746
 			ll_protocol = netdev->ll_protocol;
744
 			if ( ( rc = ll_protocol->pull ( netdev, iobuf,
747
 			if ( ( rc = ll_protocol->pull ( netdev, iobuf,
745
 							&ll_dest, &ll_source,
748
 							&ll_dest, &ll_source,
746
-							&net_proto ) ) != 0 ) {
749
+							&net_proto,
750
+							&flags ) ) != 0 ) {
747
 				free_iob ( iobuf );
751
 				free_iob ( iobuf );
748
 				continue;
752
 				continue;
749
 			}
753
 			}
751
 			/* Hand packet to network layer */
755
 			/* Hand packet to network layer */
752
 			if ( ( rc = net_rx ( iob_disown ( iobuf ), netdev,
756
 			if ( ( rc = net_rx ( iob_disown ( iobuf ), netdev,
753
 					     net_proto, ll_dest,
757
 					     net_proto, ll_dest,
754
-					     ll_source ) ) != 0 ) {
758
+					     ll_source, flags ) ) != 0 ) {
755
 				/* Record error for diagnosis */
759
 				/* Record error for diagnosis */
756
 				netdev_rx_err ( netdev, NULL, rc );
760
 				netdev_rx_err ( netdev, NULL, rc );
757
 			}
761
 			}

+ 3
- 1
src/net/rarp.c View File

38
  * @v netdev		Network device
38
  * @v netdev		Network device
39
  * @v ll_dest		Link-layer destination address
39
  * @v ll_dest		Link-layer destination address
40
  * @v ll_source		Link-layer source address
40
  * @v ll_source		Link-layer source address
41
+ * @v flags		Packet flags
41
  * @ret rc		Return status code
42
  * @ret rc		Return status code
42
  *
43
  *
43
  * This is a dummy method which simply discards RARP packets.
44
  * This is a dummy method which simply discards RARP packets.
45
 static int rarp_rx ( struct io_buffer *iobuf,
46
 static int rarp_rx ( struct io_buffer *iobuf,
46
 		     struct net_device *netdev __unused,
47
 		     struct net_device *netdev __unused,
47
 		     const void *ll_dest __unused,
48
 		     const void *ll_dest __unused,
48
-		     const void *ll_source __unused ) {
49
+		     const void *ll_source __unused,
50
+		     unsigned int flags __unused ) {
49
 	free_iob ( iobuf );
51
 	free_iob ( iobuf );
50
 	return 0;
52
 	return 0;
51
 }
53
 }

+ 5
- 2
src/net/vlan.c View File

91
 	const void *ll_dest;
91
 	const void *ll_dest;
92
 	const void *ll_source;
92
 	const void *ll_source;
93
 	uint16_t net_proto;
93
 	uint16_t net_proto;
94
+	unsigned int flags;
94
 	int rc;
95
 	int rc;
95
 
96
 
96
 	/* Strip link-layer header and preserve link-layer header fields */
97
 	/* Strip link-layer header and preserve link-layer header fields */
97
 	ll_protocol = netdev->ll_protocol;
98
 	ll_protocol = netdev->ll_protocol;
98
 	if ( ( rc = ll_protocol->pull ( netdev, iobuf, &ll_dest, &ll_source,
99
 	if ( ( rc = ll_protocol->pull ( netdev, iobuf, &ll_dest, &ll_source,
99
-					&net_proto ) ) != 0 ) {
100
+					&net_proto, &flags ) ) != 0 ) {
100
 		DBGC ( netdev, "VLAN %s could not parse link-layer header: "
101
 		DBGC ( netdev, "VLAN %s could not parse link-layer header: "
101
 		       "%s\n", netdev->name, strerror ( rc ) );
102
 		       "%s\n", netdev->name, strerror ( rc ) );
102
 		return rc;
103
 		return rc;
214
  * @v trunk		Trunk network device
215
  * @v trunk		Trunk network device
215
  * @v ll_dest		Link-layer destination address
216
  * @v ll_dest		Link-layer destination address
216
  * @v ll_source		Link-layer source address
217
  * @v ll_source		Link-layer source address
218
+ * @v flags		Packet flags
217
  * @ret rc		Return status code
219
  * @ret rc		Return status code
218
  */
220
  */
219
 static int vlan_rx ( struct io_buffer *iobuf, struct net_device *trunk,
221
 static int vlan_rx ( struct io_buffer *iobuf, struct net_device *trunk,
220
-		     const void *ll_dest, const void *ll_source ) {
222
+		     const void *ll_dest, const void *ll_source,
223
+		     unsigned int flags __unused ) {
221
 	struct vlan_header *vlanhdr = iobuf->data;
224
 	struct vlan_header *vlanhdr = iobuf->data;
222
 	struct net_device *netdev;
225
 	struct net_device *netdev;
223
 	struct ll_protocol *ll_protocol;
226
 	struct ll_protocol *ll_protocol;

+ 6
- 2
src/usr/lotest.c View File

47
  * @v netdev		Network device
47
  * @v netdev		Network device
48
  * @v ll_dest		Link-layer destination address
48
  * @v ll_dest		Link-layer destination address
49
  * @v ll_source		Link-layer source address
49
  * @v ll_source		Link-layer source address
50
+ * @v flags		Packet flags
50
  * @ret rc		Return status code
51
  * @ret rc		Return status code
51
  */
52
  */
52
 static int lotest_rx ( struct io_buffer *iobuf,
53
 static int lotest_rx ( struct io_buffer *iobuf,
53
 		       struct net_device *netdev __unused,
54
 		       struct net_device *netdev __unused,
54
 		       const void *ll_dest __unused,
55
 		       const void *ll_dest __unused,
55
-		       const void *ll_source __unused ) {
56
+		       const void *ll_source __unused,
57
+		       unsigned int flags __unused ) {
56
 	free_iob ( iobuf );
58
 	free_iob ( iobuf );
57
 	return -ENOTSUP;
59
 	return -ENOTSUP;
58
 }
60
 }
97
 	const void *ll_dest;
99
 	const void *ll_dest;
98
 	const void *ll_source;
100
 	const void *ll_source;
99
 	uint16_t net_proto;
101
 	uint16_t net_proto;
102
+	unsigned int flags;
100
 	unsigned int i;
103
 	unsigned int i;
101
 	unsigned int successes;
104
 	unsigned int successes;
102
 	int rc;
105
 	int rc;
166
 		/* Check received packet */
169
 		/* Check received packet */
167
 		if ( ( rc = receiver->ll_protocol->pull ( receiver, iobuf,
170
 		if ( ( rc = receiver->ll_protocol->pull ( receiver, iobuf,
168
 							  &ll_dest, &ll_source,
171
 							  &ll_dest, &ll_source,
169
-							  &net_proto ) ) != 0 ){
172
+							  &net_proto,
173
+							  &flags ) ) != 0 ) {
170
 			printf ( "\nFailed to strip link-layer header: %s",
174
 			printf ( "\nFailed to strip link-layer header: %s",
171
 				 strerror ( rc ) );
175
 				 strerror ( rc ) );
172
 			goto done;
176
 			goto done;

Loading…
Cancel
Save