[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-8749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14711275#comment-14711275
 ] 

ASF GitHub Bot commented on CLOUDSTACK-8749:
--------------------------------------------

Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/735#discussion_r37865908
  
    --- Diff: 
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
 ---
    @@ -286,7 +287,11 @@ private void deleteExitingLinkLocalRouteTable(String 
linkLocalBr) {
                 String[] lines = parser.getLines().split("\\n");
                 for (String line : lines) {
                     String[] tokens = line.split(" ");
    -                if (!tokens[2].equalsIgnoreCase(linkLocalBr)) {
    +                if (tokens != null && tokens.length < 2) {
    +                    continue;
    +                }
    +                final String device = tokens[2];
    +                if (!Strings.isNullOrEmpty(device) && 
!device.equalsIgnoreCase(linkLocalBr)) {
    --- End diff --
    
    Reading through this block, it feels like lines 289-293 should be extracted 
to a private method:
    
    ```
    static parseDevice(final String line) {
         final String[] tokens = line.split( " ");
         if (tokens != null && tokens.length < 2) {
            return "";
         }
         
         final String device = tokens[2];
         return Strings.isNullOrEmpty(device) : " " ? device;
    } 
    ```
    
    The extraction of this method would not only shorten the 
deleteExitingLinkLocalLocalRoutetTable method, but clearly express the intent.  
It also allows a unit test to be written to verify that parsing works as 
expected for different types of input.


> KVM: link local route cleanup
> -----------------------------
>
>                 Key: CLOUDSTACK-8749
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8749
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Rohit Yadav
>            Assignee: Rohit Yadav
>             Fix For: 4.5.3, 4.6.0
>
>
> The KVM agent attempts to delete link local interfaces whenever found, so 
> they don't conflict with the system vm's link local route on cloud0, however 
> it doesn't specify which device to delete the route for.
> The aim is to fix the edge case which (unlikely) can try to delete existing 
> cloud0 routes/interface.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to