Fixed #28 IPoE ARP

+ fix IPoE ARP interval
+ add IPoE ARP timeout/interval config
This commit is contained in:
Christian Giese
2021-05-25 10:22:02 +02:00
parent 0fd0632419
commit fa953dbf4d
6 changed files with 32 additions and 2 deletions
+2
View File
@@ -369,6 +369,8 @@ This section describes all attributes of the `ipoe` (IP over Ethernet) hierarchy
Attribute | Description | Default
--------- | ----------- | -------
`ipv4` | Enable/disable IPv4 | true (enabled)
`arp-timeout` | Initial ARP resolve timeout/retry interval in seconds | 1
`arp-interval` | Periodic ARP interval in seconds (0 means disabled) | 300
`ipv6` | Enable/disable IPv6 | true (enabled)
## PPPoE
+4
View File
@@ -580,6 +580,10 @@ typedef struct bbl_ctx_
/* IPv4 (IPoE) */
bool ipv4_enable;
/* ARP (IPoE) */
uint16_t arp_timeout;
uint16_t arp_interval;
/* IPv6 (IPoE) */
bool ipv6_enable;
+10
View File
@@ -525,6 +525,14 @@ json_parse_config (json_t *root, bbl_ctx_s *ctx) {
if (json_is_boolean(value)) {
ctx->config.ipv4_enable = json_boolean_value(value);
}
value = json_object_get(section, "arp-timeout");
if (json_is_number(value)) {
ctx->config.arp_timeout = json_number_value(value);
}
value = json_object_get(section, "arp-interval");
if (json_is_number(value)) {
ctx->config.arp_interval = json_number_value(value);
}
value = json_object_get(section, "ipv6");
if (json_is_boolean(value)) {
ctx->config.ipv6_enable = json_boolean_value(value);
@@ -1140,6 +1148,8 @@ bbl_config_init_defaults (bbl_ctx_s *ctx) {
ctx->config.authentication_timeout = 5;
ctx->config.authentication_retry = 30;
ctx->config.ipv4_enable = true;
ctx->config.arp_timeout = 1;
ctx->config.arp_interval = 300;
ctx->config.ipv6_enable = true;
ctx->config.ipcp_enable = true;
ctx->config.ipcp_request_ip = true;
+9
View File
@@ -11,6 +11,7 @@
#include "bbl_session.h"
#include "bbl_stream.h"
#include "bbl_dhcp.h"
#include "bbl_tx.h"
#include <openssl/md5.h>
#include <openssl/rand.h>
@@ -1874,6 +1875,8 @@ bbl_rx_discovery(bbl_ethernet_header_t *eth, bbl_interface_s *interface, bbl_ses
void
bbl_rx_arp(bbl_ethernet_header_t *eth, bbl_interface_s *interface, bbl_session_s *session) {
bbl_arp_t *arp = (bbl_arp_t*)eth->next;
bbl_ctx_s *ctx;
if(arp->sender_ip == session->peer_ip_address) {
if(!session->arp_resolved) {
memcpy(session->server_mac, arp->sender, ETH_ADDR_LEN);
@@ -1885,8 +1888,14 @@ bbl_rx_arp(bbl_ethernet_header_t *eth, bbl_interface_s *interface, bbl_session_s
}
} else {
if(!session->arp_resolved) {
ctx = session->interface->ctx;
bbl_rx_established_ipoe(eth, interface, session);
session->arp_resolved = true;
if(ctx->config.arp_interval) {
timer_add(&ctx->timer_root, &session->timer_arp, "ARP timeout", ctx->config.arp_interval, 0, session, &bbl_arp_timeout);
} else {
timer_del(session->timer_arp);
}
}
}
}
+4 -2
View File
@@ -1370,9 +1370,11 @@ bbl_encode_packet_arp_request (bbl_session_s *session)
arp.target_ip = session->peer_ip_address;
if(session->arp_resolved) {
timer_add(&ctx->timer_root, &session->timer_arp, "ARP timeout", 300, 0, session, &bbl_arp_timeout);
if(ctx->config.arp_interval) {
timer_add(&ctx->timer_root, &session->timer_arp, "ARP timeout", ctx->config.arp_interval, 0, session, &bbl_arp_timeout);
}
} else {
timer_add(&ctx->timer_root, &session->timer_arp, "ARP timeout", 1, 0, session, &bbl_arp_timeout);
timer_add(&ctx->timer_root, &session->timer_arp, "ARP timeout", ctx->config.arp_timeout, 0, session, &bbl_arp_timeout);
}
interface->stats.arp_tx++;
if(!ctx->stats.first_session_tx.tv_sec) {
+3
View File
@@ -9,6 +9,9 @@
#ifndef __BBL_TX_H__
#define __BBL_TX_H__
void
bbl_arp_timeout (timer_s *timer);
protocol_error_t
bbl_tx (bbl_ctx_s *ctx, bbl_interface_s *interface, uint8_t *buf, uint16_t *len);