-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[xdp]refactor offload=pktsw,csum and optimize code
- Loading branch information
Showing
23 changed files
with
1,108 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/src/main/java/io/vproxy/app/app/cmd/handle/param/OffloadHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.vproxy.app.app.cmd.handle.param; | ||
|
||
import io.vproxy.app.app.cmd.Command; | ||
import io.vproxy.app.app.cmd.Param; | ||
|
||
import java.util.Arrays; | ||
|
||
public class OffloadHandle { | ||
private OffloadHandle() { | ||
} | ||
|
||
public static final String PACKET_SWITCHING = "pktsw"; | ||
public static final String CHECKSUM = "csum"; | ||
|
||
public static boolean check(Command cmd, String... available) { | ||
if (!cmd.args.containsKey(Param.offload)) { | ||
return true; | ||
} | ||
var lsAvailable = Arrays.asList(available); | ||
var offload = cmd.args.get(Param.offload); | ||
var split = offload.split(","); | ||
for (var s : split) { | ||
s = s.trim(); | ||
if (!lsAvailable.contains(s)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
public static boolean isPacketSwitchingOffloaded(Command cmd) { | ||
return isOffloaded(cmd, PACKET_SWITCHING); | ||
} | ||
|
||
public static boolean isChecksumOffloaded(Command cmd) { | ||
return isOffloaded(cmd, CHECKSUM); | ||
} | ||
|
||
private static boolean isOffloaded(Command cmd, String match) { | ||
var offload = cmd.args.get(Param.offload); | ||
if (offload == null) { | ||
return false; | ||
} | ||
var split = offload.split(","); | ||
for (var s : split) { | ||
s = s.trim(); | ||
if (s.equals(match)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.