Shut down the PXE network stack when we are done with it. This fixes an issue where a CK804 nfe(4) would have a byte-reversed MAC address after pxeboot(8).diff -r1.9 -r1.10 src/sys/arch/i386/stand/pxeboot/dev_net.c
(jakllsch)
--- src/sys/arch/i386/stand/pxeboot/dev_net.c 2009/03/14 15:36:08 1.9
+++ src/sys/arch/i386/stand/pxeboot/dev_net.c 2009/12/13 23:01:42 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dev_net.c,v 1.9 2009/03/14 15:36:08 dsl Exp $ */ | 1 | /* $NetBSD: dev_net.c,v 1.10 2009/12/13 23:01:42 jakllsch Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Gordon W. Ross. | 8 | * by Gordon W. Ross. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -117,27 +117,26 @@ net_close(struct open_file *f) | @@ -117,27 +117,26 @@ net_close(struct open_file *f) | |||
117 | f->f_devdata = NULL; | 117 | f->f_devdata = NULL; | |
118 | /* Extra close call? */ | 118 | /* Extra close call? */ | |
119 | if (netdev_opens <= 0) | 119 | if (netdev_opens <= 0) | |
120 | return (0); | 120 | return (0); | |
121 | netdev_opens--; | 121 | netdev_opens--; | |
122 | /* Not last close? */ | 122 | /* Not last close? */ | |
123 | if (netdev_opens > 0) | 123 | if (netdev_opens > 0) | |
124 | return(0); | 124 | return(0); | |
125 | rootip.s_addr = 0; | 125 | rootip.s_addr = 0; | |
126 | if (netdev_sock >= 0) { | 126 | if (netdev_sock >= 0) { | |
127 | if (debug) | 127 | if (debug) | |
128 | printf("net_close: calling netif_close()\n"); | 128 | printf("net_close: calling netif_close()\n"); | |
129 | pxe_netif_close(netdev_sock); | 129 | pxe_netif_close(netdev_sock); | |
130 | //pxe_netif_shutdown(); /* XXX shouldn't be done here */ | |||
131 | netdev_sock = -1; | 130 | netdev_sock = -1; | |
132 | } | 131 | } | |
133 | return (0); | 132 | return (0); | |
134 | } | 133 | } | |
135 | 134 | |||
136 | int | 135 | int | |
137 | net_ioctl(struct open_file *f, u_long cmd, void *data) | 136 | net_ioctl(struct open_file *f, u_long cmd, void *data) | |
138 | { | 137 | { | |
139 | return EIO; | 138 | return EIO; | |
140 | } | 139 | } | |
141 | 140 | |||
142 | int | 141 | int | |
143 | net_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize) | 142 | net_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize) |
--- src/sys/arch/i386/stand/pxeboot/main.c 2009/09/14 11:56:27 1.21
+++ src/sys/arch/i386/stand/pxeboot/main.c 2009/12/13 23:01:42 1.22
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main.c,v 1.21 2009/09/14 11:56:27 jmcneill Exp $ */ | 1 | /* $NetBSD: main.c,v 1.22 2009/12/13 23:01:42 jakllsch Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 | 4 | * Copyright (c) 1996 | |
5 | * Matthias Drochner. All rights reserved. | 5 | * Matthias Drochner. All rights reserved. | |
6 | * Copyright (c) 1996 | 6 | * Copyright (c) 1996 | |
7 | * Perry E. Metzger. All rights reserved. | 7 | * Perry E. Metzger. All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -75,30 +75,37 @@ const struct bootblk_command commands[] | @@ -75,30 +75,37 @@ const struct bootblk_command commands[] | |||
75 | { "load", module_add }, | 75 | { "load", module_add }, | |
76 | { "vesa", command_vesa }, | 76 | { "vesa", command_vesa }, | |
77 | { NULL, NULL }, | 77 | { NULL, NULL }, | |
78 | }; | 78 | }; | |
79 | 79 | |||
80 | static void | 80 | static void | |
81 | clearit(void) | 81 | clearit(void) | |
82 | { | 82 | { | |
83 | 83 | |||
84 | if (bootconf.clear) | 84 | if (bootconf.clear) | |
85 | clear_pc_screen(); | 85 | clear_pc_screen(); | |
86 | } | 86 | } | |
87 | 87 | |||
88 | static void | |||
89 | alldone(void) | |||
90 | { | |||
91 | pxe_fini(); | |||
92 | clearit(); | |||
93 | } | |||
94 | ||||
88 | static int | 95 | static int | |
89 | bootit(const char *filename, int howto) | 96 | bootit(const char *filename, int howto) | |
90 | { | 97 | { | |
91 | if (exec_netbsd(filename, 0, howto, 0, clearit) < 0) | 98 | if (exec_netbsd(filename, 0, howto, 0, alldone) < 0) | |
92 | printf("boot: %s\n", strerror(errno)); | 99 | printf("boot: %s\n", strerror(errno)); | |
93 | else | 100 | else | |
94 | printf("boot returned\n"); | 101 | printf("boot returned\n"); | |
95 | return (-1); | 102 | return (-1); | |
96 | } | 103 | } | |
97 | 104 | |||
98 | static void | 105 | static void | |
99 | print_banner(void) | 106 | print_banner(void) | |
100 | { | 107 | { | |
101 | int base = getbasemem(); | 108 | int base = getbasemem(); | |
102 | int ext = getextmem(); | 109 | int ext = getextmem(); | |
103 | 110 | |||
104 | clearit(); | 111 | clearit(); |
--- src/sys/arch/i386/stand/pxeboot/pxe.c 2009/10/26 19:16:56 1.16
+++ src/sys/arch/i386/stand/pxeboot/pxe.c 2009/12/13 23:01:42 1.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pxe.c,v 1.16 2009/10/26 19:16:56 cegger Exp $ */ | 1 | /* $NetBSD: pxe.c,v 1.17 2009/12/13 23:01:42 jakllsch Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2001 Wasabi Systems, Inc. | 4 | * Copyright 2001 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -242,33 +242,26 @@ pxe_netif_close(int sock) | @@ -242,33 +242,26 @@ pxe_netif_close(int sock) | |||
242 | if (sock != 0) | 242 | if (sock != 0) | |
243 | printf("pxe_netif_close: sock=%d\n", sock); | 243 | printf("pxe_netif_close: sock=%d\n", sock); | |
244 | #endif | 244 | #endif | |
245 | 245 | |||
246 | uc->status = 0; | 246 | uc->status = 0; | |
247 | 247 | |||
248 | pxe_call(PXENV_UDP_CLOSE); | 248 | pxe_call(PXENV_UDP_CLOSE); | |
249 | 249 | |||
250 | if (uc->status != PXENV_STATUS_SUCCESS) | 250 | if (uc->status != PXENV_STATUS_SUCCESS) | |
251 | printf("pxe_netif_end: PXENV_UDP_CLOSE failed: 0x%x\n", | 251 | printf("pxe_netif_end: PXENV_UDP_CLOSE failed: 0x%x\n", | |
252 | uc->status); | 252 | uc->status); | |
253 | } | 253 | } | |
254 | 254 | |||
255 | void | |||
256 | pxe_netif_shutdown(void) | |||
257 | { | |||
258 | ||||
259 | pxe_fini(); | |||
260 | } | |||
261 | ||||
262 | struct iodesc * | 255 | struct iodesc * | |
263 | socktodesc(int sock) | 256 | socktodesc(int sock) | |
264 | { | 257 | { | |
265 | 258 | |||
266 | #ifdef NETIF_DEBUG | 259 | #ifdef NETIF_DEBUG | |
267 | if (sock != 0) | 260 | if (sock != 0) | |
268 | return (0); | 261 | return (0); | |
269 | else | 262 | else | |
270 | #endif | 263 | #endif | |
271 | return (&desc); | 264 | return (&desc); | |
272 | } | 265 | } | |
273 | 266 | |||
274 | /***************************************************************************** | 267 | /***************************************************************************** |
--- src/sys/arch/i386/stand/pxeboot/pxe_netif.h 2003/03/12 17:33:10 1.1
+++ src/sys/arch/i386/stand/pxeboot/pxe_netif.h 2009/12/13 23:01:42 1.2
@@ -1,5 +1,4 @@ | @@ -1,5 +1,4 @@ | |||
1 | /* $NetBSD: pxe_netif.h,v 1.1 2003/03/12 17:33:10 drochner Exp $ */ | 1 | /* $NetBSD: pxe_netif.h,v 1.2 2009/12/13 23:01:42 jakllsch Exp $ */ | |
2 | 2 | |||
3 | int pxe_netif_open(void); | 3 | int pxe_netif_open(void); | |
4 | void pxe_netif_close(int); | 4 | void pxe_netif_close(int); | |
5 | void pxe_netif_shutdown(void); |