Browse Source

Never attempt to route the broadcast address.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
5b52630a9c
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      src/net/ipv4.c

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

141
  * @v dest		Final destination address
141
  * @v dest		Final destination address
142
  * @ret dest		Next hop destination address
142
  * @ret dest		Next hop destination address
143
  * @ret miniroute	Routing table entry to use, or NULL if no route
143
  * @ret miniroute	Routing table entry to use, or NULL if no route
144
+ *
145
+ * If the route requires use of a gateway, the next hop destination
146
+ * address will be overwritten with the gateway address.
144
  */
147
  */
145
 static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
148
 static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
146
 	struct ipv4_miniroute *miniroute;
149
 	struct ipv4_miniroute *miniroute;
147
 	int local;
150
 	int local;
148
 	int has_gw;
151
 	int has_gw;
149
 
152
 
153
+	/* Never attempt to route the broadcast address */
154
+	if ( dest->s_addr == INADDR_BROADCAST )
155
+		return NULL;
156
+
157
+	/* Find first usable route in routing table */
150
 	list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
158
 	list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
151
 		local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
159
 		local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
152
 			    & miniroute->netmask.s_addr ) == 0 );
160
 			    & miniroute->netmask.s_addr ) == 0 );

Loading…
Cancel
Save