Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal log support #22

Merged
merged 5 commits into from
Sep 4, 2019
Merged

Add minimal log support #22

merged 5 commits into from
Sep 4, 2019

Conversation

sbernard31
Copy link
Contributor

@sbernard31 sbernard31 commented Aug 29, 2019

This PR aims to implements #4.
This differs a lot from what it was specify initialy.
Finally there is 6 log levels :

CRITICAL => should never happened,
ERROR => unexpected state,
WARNING => unwanted traffic (invalid packet),
INFO => not supported traffic (fragmented ip, ip option used),
DEBUG => all about NAT,
TRACE => all output we can.

A new CLI option is added :

 -l {CRITICAL,ERROR,WARNING,INFO,DEBUG,TRACE}, --loglevel {CRITICAL,ERROR,WARNING,INFO,DEBUG,TRACE}
                        Use to set logging verbosity.

The output looks like this :

Loading real servers from ulb.ini file ...
...real servers loaded : 10.0.0.1, 10.0.0.2, 10.0.0.3.

Compiling & attaching bpf code ...
... compilation and attachement succeed.

Applying config to bpf ...
Add 10.0.0.1 at index 0
Add 10.0.0.2 at index 1
Add 10.0.0.3 at index 2
[1]=10.0.0.2
[2]=10.0.0.3
[0]=10.0.0.1
[10.0.0.2]=10.0.0.2
[10.0.0.1]=10.0.0.1
[10.0.0.3]=10.0.0.3
... config applied to bpf.

Load balancing UDP traffic over lo interface for port(s) [5683] from :
 Virtual Server           Real Server(s) 
      127.0.0.1 <───┬───> 10.0.0.1       
                    ├───> 10.0.0.2       
                    └───> 10.0.0.3 

                                    ┌ 00:00:00:00:00:00/10.0.0.1        Source NAT
    00:00:00:00:00:00/10.41.44.15 <─┘ 00:00:00:00:00:00/127.0.0.1       (NEW ASSOCIATION)
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/10.41.44.15     Unhandled traffic
    00:00:00:00:00:00/10.41.44.15 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
      00:00:00:00:00:00/127.0.0.1 ─┐  00:00:00:00:00:00/127.0.0.1       Destination NAT
                                   └> 00:00:00:00:00:00/10.0.0.2        (NEW ASSOCIATION)
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/10.0.0.2        Unhandled traffic
      00:00:00:00:00:00/127.0.0.1 ─┐  00:00:00:00:00:00/127.0.0.1       Destination NAT
                                   └> 00:00:00:00:00:00/10.0.0.2        (REUSED ASSOCIATION)
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/10.0.0.2        Unhandled traffic
                                    ┌ 00:00:00:00:00:00/10.0.0.1        Source NAT
    00:00:00:00:00:00/10.41.44.15 <─┘ 00:00:00:00:00:00/127.0.0.1       (REUSED ASSOCIATION)
      00:00:00:00:00:00/127.0.0.1 <─> 00:00:00:00:00:00/10.41.44.15     Unhandled traffic
    00:00:00:00:00:00/10.41.44.15 <─> 00:00:00:00:00:00/127.0.0.1       Not UDP packet
    00:00:00:00:00:00/10.41.44.15 <── 00:00:00:00:00:00/10.0.0.2        Not associated real server
    00:00:00:00:00:00/10.41.44.15 <── 00:00:00:00:00:00/10.0.0.2        Not associated real server

Stopping by signal SIGINT(2)...
Detaching bpf code ...
... code detached.
... sbulb stopped.

Of course more could/should? be done : #21

@sbernard31 sbernard31 added this to the 0.1.0 milestone Aug 29, 2019
@sbernard31 sbernard31 mentioned this pull request Aug 29, 2019
@sbernard31 sbernard31 requested a review from oliwer August 29, 2019 10:14
int associationType; // 0:not set,1:new association, 2:existing association
// Log structure
struct logEvent {
// code identifing the kind of events
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add the port number to logEvent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the idea is to have a minimal logging facilities, that's why I didn't add it for now.
But it is in the improvements list : #21 !

We could discuss about that to know if this should be in the v0.1.0.


# Define pythons log level
logLevelNames = ["CRITICAL","ERROR","WARNING","INFO","DEBUG","TRACE"]
logging.addLevelName(5, "TRACE") # add TRACE level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the log levels, on AirVantage (and Loggly) we only use Error, Warning, Info and Debug. I would suggest doing the same. Debug and Trace are basically the same thing.
On MQTTFE, we used to differentiate Debug and Trace but we ended up merging them because it was too impractical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEBUG and TRACE is mainly for development time, not really for production.

I need 2 different log levels : one to track NAT, another for full tracing.

Here the explanation :
CRITICAL => should never happened,
ERROR => unexpected state,
WARNING => unwanted traffic (invalid packet),
INFO => not supported traffic (fragmented ip, ip option used),
DEBUG => all about NAT,
TRACE => all output we can.

}
// Should not happened, mainly needed to make verfier happy
if (rsIp == NULL) {
log(CRITICAL, ctx, INGRESS_CANNOT_CREATE_ASSO2, &logEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use the Critical level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason about that ?

@sbernard31 sbernard31 changed the base branch from check_server_alive to master September 4, 2019 09:58
@sbernard31 sbernard31 merged commit 57fbf80 into master Sep 4, 2019
@sbernard31 sbernard31 deleted the log branch September 6, 2019 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants