mirror of
https://github.com/xdp-project/BNG-router.git
synced 2024-05-06 15:54:53 +00:00
dhcp-relay: Fix a couple of compile and logic errors
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
This commit is contained in:
@ -138,7 +138,7 @@ int xdp_dhcp_relay(struct xdp_md *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* adjusting the packet head by delta size to insert option82 */
|
/* adjusting the packet head by delta size to insert option82 */
|
||||||
if (bpf_xdp_adjust_head(ctx, 0 - delta) < 0)
|
if (bpf_xdp_adjust_head(ctx, 0 - (int)delta) < 0)
|
||||||
return XDP_ABORTED;
|
return XDP_ABORTED;
|
||||||
|
|
||||||
data_end = (void *)(long)ctx->data_end;
|
data_end = (void *)(long)ctx->data_end;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0 */
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
static const char *__doc__ = "DHCP relay program to add Option 82\n";
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -102,12 +101,12 @@ int main(int argc, char **argv)
|
|||||||
char dev[IF_NAMESIZE] = "";
|
char dev[IF_NAMESIZE] = "";
|
||||||
bool do_unload = 0;
|
bool do_unload = 0;
|
||||||
struct bpf_map *map = NULL;
|
struct bpf_map *map = NULL;
|
||||||
struct bpf_obj *obj = NULL;
|
struct bpf_object *obj = NULL;
|
||||||
int map_fd;
|
int map_fd;
|
||||||
int key = 0;
|
int key = 0;
|
||||||
char server[15] = "";
|
struct in_addr addr = {};
|
||||||
struct in_addr addr;
|
bool addr_set = false;
|
||||||
__u16 ifindex;
|
__u16 ifindex = 0;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "hui:d:m:", options, NULL)) !=
|
while ((opt = getopt_long(argc, argv, "hui:d:m:", options, NULL)) !=
|
||||||
-1) {
|
-1) {
|
||||||
@ -128,6 +127,7 @@ int main(int argc, char **argv)
|
|||||||
optarg);
|
optarg);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
addr_set = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (strcmp(optarg, "skb") == 0) {
|
if (strcmp(optarg, "skb") == 0) {
|
||||||
@ -150,6 +150,15 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ifindex) {
|
||||||
|
fprintf(stderr, "Missing ifname\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (!addr_set) {
|
||||||
|
fprintf(stderr, "Missing server address\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (do_unload)
|
if (do_unload)
|
||||||
return xdp_link_detach(ifindex, xdp_flags);
|
return xdp_link_detach(ifindex, xdp_flags);
|
||||||
|
|
||||||
@ -161,7 +170,7 @@ int main(int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (prog_fd <= 0) {
|
if (prog_fd <= 0) {
|
||||||
printf("ERR: loading file: %s\n");
|
printf("ERR: loading file: %s\n", filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user