iPXE discussion forum
use-cached not working? - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: use-cached not working? (/showthread.php?tid=8479)



use-cached not working? - korekhov - 2017-03-04 04:53

Hello all!

We have been using iPXE's ability to use cached IP from PXE for several years, but in latest versions of iPXE that I had to recompile for support of newer NICs, I don't seem to be able to use that anymore - iPXE always goes back to DHCP server to request an IP. Because of different UUIDs, this results in 2 IPs given to the same MAC, which is wasteful:

iPXE> echo ${use-cached}
1
iPXE> dhcp net0
Configuring (net0 38:ea:a7:31:3f:68).................. ok
iPXE>

lease 10.28.7.245 {
starts 6 2017/03/04 02:36:27;
ends 6 2017/03/04 02:37:33;
tstp 6 2017/03/04 02:37:33;
cltt 6 2017/03/04 02:36:27;
binding state free;
hardware ethernet 38:ea:a7:31:3f:68;
uid "\0018\352\2471?h";
}
lease 10.28.7.160 {
starts 6 2017/03/04 02:37:33;
ends 6 2017/03/04 02:47:33;
cltt 6 2017/03/04 02:37:33;
binding state active;
next binding state free;
hardware ethernet 38:ea:a7:31:3f:68;
}


Here's the way I compiled kkpxe just tonight off the latest git repo:

make bin/undionly.kkpxe EMBED=../embedded-script.pxe,/usr/lib/syslinux/pxelinux.0

Content of embedded-script.pxe:

#!ipxe
set use-cached 1
prompt --key 0x02 --timeout 5000 Press Ctrl-B for command line && shell ||
dhcp
# passed as BOOTIF=${bootif} to kernels, later.
set bootif:string 01-${mac:hexhyp}
# If there is a DHCP option for "directory" set, assume that's a
# new bootmethod URL.
isset ${210:string} && set bootmethod:string ${210:string} && goto chainstart ||
set bootmethod:string tftp://${next-server}/
:chainstart
# bootmethod, ipargs, bootif used by chained scripts
chain ${bootmethod}pxelinux.cfg/${bootif}.ipxe ||
chain pxelinux.0 ||
shell
EOF

Am I missing something here? Can't put my finger on it...
Thanks!
Forgot to mention that I've made the following modifications to enable interesting to us features:

config/console.h
-//#define CONSOLE_SERIAL /* Serial port console */
+#define CONSOLE_SERIAL /* Serial port console */

-//#define CONSOLE_SYSLOG /* Syslog console */
+#define CONSOLE_SYSLOG /* Syslog console */

config/general.h
-#undef NET_PROTO_IPV6 /* IPv6 protocol */
+#define NET_PROTO_IPV6 /* IPv6 protocol */

-#undef DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */
+#define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */

-//#define NSLOOKUP_CMD /* DNS resolving command */
-//#define TIME_CMD /* Time commands */
-//#define DIGEST_CMD /* Image crypto digest commands */
-//#define LOTEST_CMD /* Loopback testing commands */
-//#define VLAN_CMD /* VLAN commands */
-//#define PXE_CMD /* PXE commands */
-//#define REBOOT_CMD /* Reboot command */
-//#define POWEROFF_CMD /* Power off command */
-//#define IMAGE_TRUST_CMD /* Image trust management commands */
-//#define PCI_CMD /* PCI commands */
-//#define PARAM_CMD /* Form parameter commands */
-//#define NEIGHBOUR_CMD /* Neighbour management commands */
-//#define PING_CMD /* Ping command */
-//#define CONSOLE_CMD /* Console command */
-//#define IPSTAT_CMD /* IP statistics commands */
-//#define PROFSTAT_CMD /* Profiling commands */
-//#define NTP_CMD /* NTP commands */
-//#define CERT_CMD /* Certificate management commands */
+#define NSLOOKUP_CMD /* DNS resolving command */
+#define TIME_CMD /* Time commands */
+#define DIGEST_CMD /* Image crypto digest commands */
+#define LOTEST_CMD /* Loopback testing commands */
+#define VLAN_CMD /* VLAN commands */
+#define PXE_CMD /* PXE commands */
+#define REBOOT_CMD /* Reboot command */
+#define POWEROFF_CMD /* Power off command */
+#define IMAGE_TRUST_CMD /* Image trust management commands */
+#define PCI_CMD /* PCI commands */
+#define PARAM_CMD /* Form parameter commands */
+#define NEIGHBOUR_CMD /* Neighbour management commands */
+#define PING_CMD /* Ping command */
+#define CONSOLE_CMD /* Console command */
+#define IPSTAT_CMD /* IP statistics commands */
+#define PROFSTAT_CMD /* Profiling commands */
+#define NTP_CMD /* NTP commands */
+#define CERT_CMD /* Certificate management commands */
Just recompiled kkpxe w/o any changes to any of the header files and got the same result Sad


RE: use-cached not working? - NiKiZe - 2017-03-04 16:57

the normal way to use orignal dhcp setting is to use ifopen not dhcp.

use-cached went away in 2013 https://git.ipxe.org/ipxe.git/commitdiff/10d19bd2ac302cd5237e7b1ca200760594a3c8c2

also undionly.kkpxe (or any version of .kkpxe) is likely not what you want and can cause several issues in regards to closing the device.
instead use .kpxe (one k)


SOLVED: use-cached not working? - korekhov - 2017-03-06 20:32

[quote='NiKiZe' pid='13745' dateline='1488643052']
the normal way to use orignal dhcp setting is to use ifopen not dhcp.

Thanks a lot, NiKiZe!


RE: unSOLVED: use-cached not working? - korekhov - 2017-06-15 22:17

(2017-03-04 16:57)NiKiZe Wrote:  the normal way to use original dhcp setting is to use ifopen not dhcp.

Hmm, just tried the latest iPXE source to build UEFI image with embedded script with above command and found that it does not work like it does for regular/BIOS image. So, to make it work for now, I had to add "dhcp" to embedded script. That always results in resending DHCP requests.

Is this a bug in UEFI and there's no way for it to reuse DHCP data from PXE?
Or there's some other way that needs to be used for UEFI specifically?

Thanks!


RE: use-cached not working? - NiKiZe - 2017-06-19 11:44

as you noticed the cached feature does not work in EFI don't remember if it's not possible or just not implemented.

I would propose a script similar to
Code:
ifopen net0
iseq ${platform} efi && dhcp ||

That would run dhcp only if in efi mode