Skip to content

Commit

Permalink
automatic commit at releng box
Browse files Browse the repository at this point in the history
  • Loading branch information
mc36 committed Feb 5, 2025
1 parent f943b98 commit ff2c299
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 22 deletions.
7 changes: 4 additions & 3 deletions src/org/freertr/rtr/rtrBgpDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,10 @@ public static List<packHolder> logs2pcks(List<String> txt) {
* @param ntry route to convert
* @param ipv ip version
* @param pck target packet
* @param tmp temp packet
* @param rch true if reachable, false if unreachable
*/
public static void witeFormat(int sfi, tabRouteEntry<addrIP> ntry, int ipv, packHolder pck, boolean rch) {
public static void witeFormat(int sfi, tabRouteEntry<addrIP> ntry, int ipv, packHolder pck, packHolder tmp, boolean rch) {
pck.clear();
ntry = ntry.copyBytes(tabRoute.addType.better);
if (ntry.best.nextHop == null) {
Expand All @@ -495,9 +496,9 @@ public static void witeFormat(int sfi, tabRouteEntry<addrIP> ntry, int ipv, pack
List<tabRouteEntry<addrIP>> lst = new ArrayList<tabRouteEntry<addrIP>>();
lst.add(ntry);
if (rch) {
rtrBgpUtil.createReachable(null, pck, new packHolder(true, true), sfi, false, true, true, lst);
rtrBgpUtil.createReachable(null, pck, tmp, sfi, false, true, true, lst);
} else {
rtrBgpUtil.createWithdraw(null, pck, new packHolder(true, true), sfi, false, lst);
rtrBgpUtil.createWithdraw(null, pck, tmp, sfi, false, lst);
}
rtrBgpUtil.createHeader(pck, rtrBgpUtil.msgUpdate);
}
Expand Down
3 changes: 0 additions & 3 deletions src/org/freertr/rtr/rtrBgpGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ public rtrBgpGroup(rtrBgp parent, int num) {
groupNum = num;
}

public void flapBgpConn() {
}

public void doTempCfg(String cmd, boolean negated) {
}

Expand Down
41 changes: 41 additions & 0 deletions src/org/freertr/rtr/rtrBgpNeigh.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.freertr.rtr;

import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import org.freertr.addr.addrIP;
Expand All @@ -10,6 +11,7 @@
import org.freertr.ip.ipFwdIface;
import org.freertr.ip.ipFwdTab;
import org.freertr.pack.packDnsRec;
import org.freertr.pack.packHolder;
import org.freertr.pipe.pipeLine;
import org.freertr.pipe.pipeSide;
import org.freertr.prt.prtAccept;
Expand Down Expand Up @@ -605,10 +607,49 @@ public String toString() {
return "" + peerAddr;
}

/**
* flap connection
*/
public void flapBgpConn() {
conn.closeNow();
}

/**
* save table
*
* @param fil file to use
* @param safi safi to refresh
*/
public void saveTable(RandomAccessFile fil, int safi) {
saveTable(fil, safi, conn.getLearned(safi), false);
saveTable(fil, safi, conn.getAdverted(safi), true);
}

private void saveTable(RandomAccessFile fil, int safi, tabRoute<addrIP> table, boolean dir) {
if (table == null) {
return;
}
packHolder pck = new packHolder(true, true);
packHolder tmp = new packHolder(true, true);
byte[] hdr = new byte[128];
for (int i = 0; i < table.size(); i++) {
tabRouteEntry<addrIP> ntry = table.get(i);
if (ntry == null) {
continue;
}
rtrBgpDump.witeFormat(safi, ntry, lower.fwdCore.ipVersion, pck, tmp, true);
int len = rtrBgpMrt.putMrtHeader(hdr, ntry.best.time, dir, remoteAs, localAs, peerAddr, localAddr, pck.dataSize());
pck.putCopy(hdr, 0, 0, len);
pck.putSkip(len);
pck.merge2beg();
byte[] buf = pck.getCopy();
try {
fil.write(buf);
} catch (Exception e) {
}
}
}

public void doTempCfg(String cmd, boolean negated) {
}

Expand Down
5 changes: 0 additions & 5 deletions src/org/freertr/rtr/rtrBgpParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -2270,11 +2270,6 @@ public List<String> getParamCfg(String beg, String nei, int filter) {
return l;
}

/**
* flap connection
*/
public abstract void flapBgpConn();

/**
* template configuration
*
Expand Down
6 changes: 0 additions & 6 deletions src/org/freertr/rtr/rtrBgpTemp.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public int compareTo(rtrBgpTemp o) {
return tempName.compareTo(o.tempName);
}

/**
* flap connection
*/
public void flapBgpConn() {
}

/**
* configure
*
Expand Down
32 changes: 31 additions & 1 deletion src/org/freertr/user/userClear.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.freertr.user;

import java.io.File;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import org.freertr.addr.addrIP;
Expand Down Expand Up @@ -214,7 +215,7 @@ public cfgAlias doer() {
cmd.error("no such interface");
return null;
}
if (ifc.pppoeS==null) {
if (ifc.pppoeS == null) {
cmd.error("protocol not enabled");
return null;
}
Expand Down Expand Up @@ -1035,6 +1036,35 @@ private void doClearIpXbgp(tabRouteAttr.routeType afi) {
}
return;
}
if (a.equals("save")) {
long safi = rtrBgpParam.string2mask(cmd.word());
if (safi < 1) {
return;
}
int sfi = r.bgp.mask2safi(safi);
if (sfi < 1) {
return;
}
a = cmd.word();
cmd.error("opening " + a);
RandomAccessFile fs = null;
try {
fs = new RandomAccessFile(new File(a), "rw");
fs.setLength(0);
} catch (Exception e) {
return;
}
for (int i = 0; i < neis.size(); i++) {
rtrBgpNeigh nei = neis.get(i);
cmd.error("saving " + nei.peerAddr);
nei.saveTable(fs, sfi);
}
try {
fs.close();
} catch (Exception e) {
}
return;
}
int mod = 0;
if (a.equals("in")) {
mod = 1;
Expand Down
15 changes: 15 additions & 0 deletions src/org/freertr/user/userExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ private void getHelpClearIpX(userHelping hl) {
hl.add(null, "5 6 peer select address");
hl.add(null, "6 7 <addr> neighbor address regexp");
hl.add(null, "7 . hard flap session");
hl.add(null, "7 8 save export an afi");
rtrBgpParam.getAfiList(hl, "8 9", "clear", false);
hl.add(null, "9 . <name> name of file");
hl.add(null, "7 8 in send route refresh");
hl.add(null, "7 8 out resend prefixes");
hl.add(null, "7 8 add add an afi");
Expand All @@ -214,27 +217,39 @@ private void getHelpClearIpX(userHelping hl) {
hl.add(null, "5 6 asn select asn");
hl.add(null, "6 7 <num> neighbor asn regexp");
hl.add(null, "7 . hard flap session");
hl.add(null, "7 8 save export an afi");
rtrBgpParam.getAfiList(hl, "8 9", "clear", false);
hl.add(null, "9 . <name> name of file");
hl.add(null, "7 8 in send route refresh");
hl.add(null, "7 8 out resend prefixes");
hl.add(null, "7 8 add add an afi");
hl.add(null, "7 8 del delete an afi");
rtrBgpParam.getAfiList(hl, "8 .", "clear", false);
hl.add(null, "5 7 ibgp select ibgp peers");
hl.add(null, "7 . hard flap session");
hl.add(null, "7 8 save export an afi");
rtrBgpParam.getAfiList(hl, "8 9", "clear", false);
hl.add(null, "9 . <name> name of file");
hl.add(null, "7 8 in send route refresh");
hl.add(null, "7 8 out resend prefixes");
hl.add(null, "7 8 add add an afi");
hl.add(null, "7 8 del delete an afi");
rtrBgpParam.getAfiList(hl, "8 .", "clear", false);
hl.add(null, "5 7 ebgp select ebgp peers");
hl.add(null, "7 . hard flap session");
hl.add(null, "7 8 save export an afi");
rtrBgpParam.getAfiList(hl, "8 9", "clear", false);
hl.add(null, "9 . <name> name of file");
hl.add(null, "7 8 in send route refresh");
hl.add(null, "7 8 out resend prefixes");
hl.add(null, "7 8 add add an afi");
hl.add(null, "7 8 del delete an afi");
rtrBgpParam.getAfiList(hl, "8 .", "clear", false);
hl.add(null, "5 7 all select every peer");
hl.add(null, "7 . hard flap session");
hl.add(null, "7 8 save export an afi");
rtrBgpParam.getAfiList(hl, "8 9", "clear", false);
hl.add(null, "9 . <name> name of file");
hl.add(null, "7 8 in send route refresh");
hl.add(null, "7 8 out resend prefixes");
hl.add(null, "7 8 add add an afi");
Expand Down
8 changes: 4 additions & 4 deletions src/org/freertr/user/userShow.java
Original file line number Diff line number Diff line change
Expand Up @@ -4802,11 +4802,11 @@ private void doShowIpXbgp(tabRouteAttr.routeType afi) {
return;
}
packHolder pck = new packHolder(true, true);
rtrBgpDump.witeFormat(sfi, ntry, r.bgp.fwdCore.ipVersion, pck, true);
packHolder tmp = new packHolder(true, true);
rtrBgpDump.witeFormat(sfi, ntry, r.bgp.fwdCore.ipVersion, pck, tmp, true);
ipCor4 ic4 = new ipCor4();
ipCor6 ic6 = new ipCor6();
tabGen<tabSessionEntry> ses = new tabGen<tabSessionEntry>();
packHolder tmp = new packHolder(true, true);
List<String> l = rtrBgpDump.dumpPacketFull(ic4, ic6, ses, tmp, pck);
rdr.putStrArr(l);
return;
Expand Down Expand Up @@ -4835,11 +4835,11 @@ private void doShowIpXbgp(tabRouteAttr.routeType afi) {
return;
}
packHolder pck = new packHolder(true, true);
rtrBgpDump.witeFormat(sfi, ntry, r.bgp.fwdCore.ipVersion, pck, false);
packHolder tmp = new packHolder(true, true);
rtrBgpDump.witeFormat(sfi, ntry, r.bgp.fwdCore.ipVersion, pck, tmp, false);
ipCor4 ic4 = new ipCor4();
ipCor6 ic6 = new ipCor6();
tabGen<tabSessionEntry> ses = new tabGen<tabSessionEntry>();
packHolder tmp = new packHolder(true, true);
List<String> l = rtrBgpDump.dumpPacketFull(ic4, ic6, ses, tmp, pck);
rdr.putStrArr(l);
return;
Expand Down

0 comments on commit ff2c299

Please sign in to comment.