Sun Dec 13 23:01:42 2009 UTC ()
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).


(jakllsch)
diff -r1.9 -r1.10 src/sys/arch/i386/stand/pxeboot/dev_net.c
diff -r1.21 -r1.22 src/sys/arch/i386/stand/pxeboot/main.c
diff -r1.16 -r1.17 src/sys/arch/i386/stand/pxeboot/pxe.c
diff -r1.1 -r1.2 src/sys/arch/i386/stand/pxeboot/pxe_netif.h

cvs diff -r1.9 -r1.10 src/sys/arch/i386/stand/pxeboot/dev_net.c (expand / switch to unified diff)

--- 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
136int 135int
137net_ioctl(struct open_file *f, u_long cmd, void *data) 136net_ioctl(struct open_file *f, u_long cmd, void *data)
138{ 137{
139 return EIO; 138 return EIO;
140} 139}
141 140
142int 141int
143net_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize) 142net_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize)

cvs diff -r1.21 -r1.22 src/sys/arch/i386/stand/pxeboot/main.c (expand / switch to unified diff)

--- 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
80static void 80static void
81clearit(void) 81clearit(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
 88static void
 89alldone(void)
 90{
 91 pxe_fini();
 92 clearit();
 93}
 94
88static int  95static int
89bootit(const char *filename, int howto) 96bootit(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
98static void 105static void
99print_banner(void) 106print_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();

cvs diff -r1.16 -r1.17 src/sys/arch/i386/stand/pxeboot/pxe.c (expand / switch to unified diff)

--- 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
255void 
256pxe_netif_shutdown(void) 
257{ 
258 
259 pxe_fini(); 
260} 
261 
262struct iodesc * 255struct iodesc *
263socktodesc(int sock) 256socktodesc(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/*****************************************************************************

cvs diff -r1.1 -r1.2 src/sys/arch/i386/stand/pxeboot/pxe_netif.h (expand / switch to unified diff)

--- 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
3int pxe_netif_open(void); 3int pxe_netif_open(void);
4void pxe_netif_close(int); 4void pxe_netif_close(int);
5void pxe_netif_shutdown(void);