dnsmasq proxyDHCP PXE and EFI "start_image() returned Invalid Parameter"

I'm tying to install a PXE install server with dnsmasq in proyxDHCP mode. So far legacy BIOS install is working. When I try to use EFI it fails.

With dhcpd the EFI boot is working. Therefore the shim.efi file should be fine.

Unable to fetch TFTP image: Invalid Parameter
start_image() returned Invalid Parameter

Image error message

[root@pxetestsrv tftpboot]# ll
total 2448
-rw-r--r-- 1 root root   20832 Apr  6 13:43 chain.c32
-rw-r--r-- 1 root root     175 Apr 10 09:47 grub.cfg
-rwxr-xr-x 1 root root 1024464 Apr  6 15:48 grubx64.efi
drwxr-xr-x 2 root root      39 Apr  9 09:48 images
-rw-r--r-- 1 root root   33756 Apr  6 13:43 mboot.c32
-rw-r--r-- 1 root root   26268 Apr  6 13:43 memdisk
-rw-r--r-- 1 root root   55140 Apr  6 13:43 menu.c32
-rw-r--r-- 1 root root   26826 Apr  6 13:43 pxelinux.0
drwxr-xr-x 2 root root      21 Apr  6 14:51 pxelinux.cfg
-rw-r--r-- 1 root root 1295704 Apr  6 15:48 shim.efi

proxydhcp.conf:

# Don't function as a DNS server:
port=0

# Log lots of extra information about DHCP transactions.
log-dhcp

# Set the root directory for files available via FTP.
enable-tftp
tftp-root=/var/lib/tftpboot

# PXE menu.  The first part is the text displayed to the user.  The second is the timeout, in seconds.
pxe-prompt="Booting PXE Client", 1

# The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86,
# Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI, ARM_EFI and X86-64_EFI
# This option is first and will be the default if there is no input from the user.
# PXEClient:Arch:00000
 pxe-service=X86PC, "Boot BIOS PXE", pxelinux
# PXEClient:Arch:00007
 pxe-service=BC_EFI, "Boot UEFI PXE-BC", shim.efi
# PXEClient:Arch:00009
 pxe-service=X86-64_EFI, "Boot UEFI PXE-64", shim.efi
 dhcp-range=172.27.224.95,proxy

In the logs:

dnsmasq[30104]: started, version 2.76 DNS disabled
dnsmasq[30104]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify
dnsmasq-dhcp[30104]: DHCP, proxy on subnet 172.27.224.95
dnsmasq-tftp[30104]: TFTP root is /var/lib/tftpboot
dnsmasq-dhcp[30104]: 2149063664 available DHCP subnet: 172.27.224.95/255.255.255.0
dnsmasq-dhcp[30104]: 2149063664 vendor class: PXEClient:Arch:00009:????:??????
dnsmasq-dhcp[30104]: 2149063664 PXE(eth0) 00:50:56:b7:54:68 proxy
dnsmasq-dhcp[30104]: 2149063664 tags: eth0
dnsmasq-dhcp[30104]: 2149063664 next server: 172.27.224.95
dnsmasq-dhcp[30104]: 2149063664 broadcast response
dnsmasq-dhcp[30104]: 2149063664 sent size:  1 option: 53 message-type  2
dnsmasq-dhcp[30104]: 2149063664 sent size:  4 option: 54 server-identifier  172.27.224.95
dnsmasq-dhcp[30104]: 2149063664 sent size:  9 option: 60 vendor-class  00:ab:dc:33:23:23:23:23:23
dnsmasq-dhcp[30104]: 2149063664 sent size: 17 option: 97 client-machine-id  00:23:23:23:23:23:23:23:23:23:23:23:23:23...
dnsmasq-dhcp[30104]: 2149063664 available DHCP subnet: 172.27.224.95/255.255.255.0
dnsmasq-dhcp[30104]: 2149063664 vendor class: PXEClient:Arch:00009:????:??????
dnsmasq-dhcp[30104]: 180220542 available DHCP subnet: 172.27.224.95/255.255.255.0
dnsmasq-dhcp[30104]: 180220542 vendor class: PXEClient:Arch:00009:????:??????
dnsmasq-dhcp[30104]: 180220542 PXE(eth0) 00:50:56:b7:54:68 proxy
dnsmasq-dhcp[30104]: 180220542 tags: eth0
dnsmasq-dhcp[30104]: 180220542 bootfile name: shim.efi
dnsmasq-dhcp[30104]: 180220542 server name: 172.27.224.95
dnsmasq-dhcp[30104]: 180220542 next server: 172.27.224.95
dnsmasq-dhcp[30104]: 180220542 sent size:  1 option: 53 message-type  5
dnsmasq-dhcp[30104]: 180220542 sent size:  4 option: 54 server-identifier  172.27.224.95
dnsmasq-dhcp[30104]: 180220542 sent size:  9 option: 60 vendor-class  00:ab:dc:33:23:23:23:23:23
dnsmasq-dhcp[30104]: 180220542 sent size: 17 option: 97 client-machine-id  00:23:23:23:23:23:23:23:23:23:23:23:23:23...
dnsmasq-tftp[30104]: error 8 User aborted the transfer received from 172.27.224.251
dnsmasq-tftp[30104]: failed sending /var/lib/tftpboot/shim.efi to 172.27.224.251
dnsmasq-tftp[30104]: sent /var/lib/tftpboot/shim.efi to 172.27.224.251

I ran into the same issue and spent a while troubleshooting. The shim and grub2 work in a weird way. You HAVE to have your primary DHCP have "next-server" set to your proxyDHCP server. iPXE and BIOS booting didnt care if you had a proxy dhcp server without next-server set, grub and the shims seem to fail without it.