Skip to content

Commit

Permalink
changing signal handling in vc5ng for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcoles committed Apr 3, 2023
1 parent e679150 commit 1dda870
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 48 deletions.
19 changes: 7 additions & 12 deletions cmd/vc5ng.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func main() {
ulimit()

if *sock != "" {
signal.Ignore(syscall.SIGQUIT, syscall.SIGINT)
//signal.Ignore(syscall.SIGQUIT, syscall.SIGINT)
signal.Ignore(syscall.SIGHUP)
vc5.NetnsServer(*sock)
return
}
Expand Down Expand Up @@ -182,23 +183,17 @@ func main() {
pool := NewBGPPool(ip, conf.RHI.AS_Number, conf.RHI.Hold_Time, conf.RHI.Communities(), conf.RHI.Peers)

sig := make(chan os.Signal)
//signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGINT)
signal.Notify(sig)
//signal.Notify(sig, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM)
signal.Notify(sig, syscall.SIGUSR2, syscall.SIGQUIT)
//signal.Notify(sig) // alll

go func() {
for {
s := <-sig
switch s {
case syscall.SIGURG:
case syscall.SIGCHLD:
case syscall.SIGWINCH:
default:
lb.DEFCON(0)
lb.Close()
time.Sleep(1 * time.Second)
os.Remove(temp.Name())
log.Fatal("EXITING ", s)
case syscall.SIGQUIT:
fallthrough
case syscall.SIGUSR2:
log.Println("RELOAD")
time.Sleep(1 * time.Second)

Expand Down
21 changes: 1 addition & 20 deletions kernel/bpf/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ struct natval {
__be32 src_ip;
__be32 dst_ip;
__u16 vlan;
__u8 multi;
__u8 pad;
__u8 pad[2];
__u8 src_mac[6];
__u8 dst_mac[6];
};
Expand Down Expand Up @@ -703,25 +702,7 @@ static __always_inline int nat_packet(struct xdp_md *ctx, struct ethhdr *eth, st
return XDP_DROP;
}

/*
if(outgoing) {
if(MODE == MODE_VLAN) {
if(nval->vlan != 0 && vlan_tag_push(ctx, eth, nval->vlan) < 0)
return XDP_DROP;
}
} else {
if(tag != NULL && vlan_tag_pop(ctx, eth) < 0)
return XDP_DROP;
}
*/


if(outgoing) {
//if(nval->vlan != 0) {
// if(!(nval->multi)) {
// if(vlan_tag_push(ctx, eth, nval->vlan) < 0) return XDP_DROP;
// }
//}
} else {
if(tag != NULL && vlan_tag_pop(ctx, eth) < 0) return XDP_DROP;
}
Expand Down
24 changes: 8 additions & 16 deletions kernel/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ type natkey struct {
}

type natval struct {
ifindex uint32 //__u32 ifindex;
src_ip IP4 //__be32 src_ip;
dst_ip IP4 //__be32 dst_ip;
vlan uint16 //__u16 vlan;
multi byte //__u8 multi;
_pad byte //__u8 _pad];
src_mac MAC //__u8 src_mac[6];
dst_mac MAC //__u8 dst_mac[6];
ifindex uint32 //__u32 ifindex;
src_ip IP4 //__be32 src_ip;
dst_ip IP4 //__be32 dst_ip;
vlan uint16 //__u16 vlan;
_pad [2]byte //__u8 _pad];
src_mac MAC //__u8 src_mac[6];
dst_mac MAC //__u8 dst_mac[6];
}

func (n *natkey) String() string {
Expand Down Expand Up @@ -165,21 +164,14 @@ func (n *NAT) nat(h *Healthchecks, natMap map[[2]IP4]uint16) {

n.Logger.DEBUG("vip/rip/vlanid/vlanip", vip, rip, vlanid, vlanip)

var multi uint8

//if n.MultiNIC {
//physmac = MAC{0x00, 0x50, 0x56, 0x90, 0xad, 0x24}
//physif = 21
multi = 1
if vlanid != 0 {
physmac = ifmacs[vlanid]
physif = uint32(redirect[vlanid])
}
//}

// outgoing probes
key := natkey{src_ip: vc5bip, src_mac: vc5bmac, dst_ip: nat, dst_mac: vc5amac}
val := natval{src_ip: vlanip, src_mac: physmac, dst_ip: vip, dst_mac: realmac, ifindex: physif, vlan: vlanid, multi: multi}
val := natval{src_ip: vlanip, src_mac: physmac, dst_ip: vip, dst_mac: realmac, ifindex: physif, vlan: vlanid}
n.Logger.DEBUG("nat", "Outgoing map", key.String(), val.String())

table[key] = true
Expand Down

0 comments on commit 1dda870

Please sign in to comment.